对拍
shell
1 2 3 4 5 6 7 8 9 10 11 12 |
#! /bin/bash while true; do ./data > data.in ./1 <data.in >1.out ./2 <data.in >2.out if diff 1.out 2.out; then printf "AC\n" else printf "Wa\n" exit 0 fi done |
c++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <bits/stdc++.h> using namespace std; int main() { // windows下改为fc和对应的文件路径 for (int T = 1; T <= 10000; ++ T) { system("./data >data.in"); double st = clock(); system("./1 <data.in >1.out"); double ed = clock(); system("./2 <data.in >2.out"); if (system("diff 1.out 2.out")) { puts("WA"); return 0; } else { printf("AC, test point #%d, time %.0lfms\n", T, ed - st); } } } |
data
1 2 3 4 5 6 7 8 9 10 11 |
#include <bits/stdc++.h> using namespace std; int main() { srand(time(0)); int n = rand() % (int)1e6 + 1; printf("%d\n", n); for (int i = 1; i <= n; ++ i) printf("%d ", rand() % int(1e9) + 1); } |
发表回复