赞
踩
//文件名:My.cpp #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a(n); vector<int> b(n); function<void(int, int)> solve = [&](int l, int r){ if(r <= l) return; int mid = ((r - l) >> 1) + l; solve(l, mid); solve(mid + 1, r); int i = l; int j = mid + 1; int k = 0; while(i <= mid && j <= r){ if(a[i] < a[j]){ b[k++] = a[i++]; }else{ b[k++] = a[j++]; } } while(i <= mid){ b[k++] = a[i++]; } while(j <= r){ b[k++] = a[j++]; } k = 0; for(i=l;i<=r;i++){ a[i] = b[k++]; } }; for(int i=0;i<n;i++){ cin >> a[i]; } solve(0, n-1); for(int i=0;i<n;i++){ cout << a[i] << ' '; } return 0; }
//文件名:std.cpp #include <iostream> #include <cstring> #include <algorithm> #include <queue> #include <stack> #include <vector> #include <cmath> #include <cstdio> #include <map> using namespace std; typedef long long ll; const int MAXN = 2e5 + 100; const int INF = 0x3f3f3f3f; int Data[MAXN]; void quicksort(int l, int r){ int mid = Data[(l + r) / 2]; int i = l; int j = r; do{ while(Data[i] < mid) i++; while(mid < Data[j]) j--; if(i <= j){ swap(Data[i], Data[j]); i++; j--; } }while(i <= j); if(l < j) quicksort(l, j); if(r > i) quicksort(i, r); } int main(){ ios::sync_with_stdio(false); int n; cin >> n; for(int i=1;i<=n;i++) cin >> Data[i]; quicksort(1, n); for(int i=1;i<=n;i++) cout << Data[i] << ' '; return 0; }
My.out
和std.out
,现在写一个随机数生成程序#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; unsigned seed = chrono::system_clock::now().time_since_epoch().count(); mt19937 rand_num(seed); uniform_int_distribution<int> dist(1, (int)1e5); n = dist(rand_num); uniform_int_distribution<int> dd((int)-1e9, (int)1e9); cout << n << '\n'; for(int i=1;i<=n;i++){ cout << dd(rand_num) << ' '; } return 0; }
rand.out
,接下来写一个脚本,命名为solve.sh
#!/bin/bash i=1 while true; do ./rand.out > input.txt ./std.out <input.txt >output.txt ./My.out <input.txt >output2.txt echo test $i i=$(($i+1)) if diff output.txt output2.txt; then printf "AC\n" else printf "Wa\n" exit 0 fi done
sh solve.sh
,会是下面的画面,当然终端可能颜色不一样 if(n < 100){
a[1] = 1;
}
.bat
的文件如下@echo off
:loop
rand.exe > input.txt
solve.exe < input.txt > output.txt
std.exe < input.txt > output2.txt
fc output.txt output2.txt
if not errorlevel 1 goto loop
pause
:end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。