关于Windows下的对拍
对拍是什么,对拍实际上是一种用一道题暴力(一定正确,时间复杂度不重要)的程序来检验你写的正解(你认为可以AC的代码)。
下面放上我常在Windows上常用的对拍器
#include<bits/stdc++.h>
using namespace std;
int main() {
system("g++ datamaker.cpp -o datamaker.exe");
cout << "datamaker compiled" << endl;
system("g++ std.cpp -o std.exe");
cout << "std compiled" << endl;
system("g++ yours.cpp -o yours.exe");
cout << "yours compiled" << endl;
int T = 0;
while (++T) {
cout << "[info] testdata<" << T << ">" << endl;
double a = clock() / 1000.0;
system("datamaker.exe > data.in");
double b = clock() / 1000.0;
cout << "[info] data made in " << b - a << "s" << endl;
system("std.exe < data.in > exp.out");
double c = clock() / 1000.0;
cout << "[info] std finished in " << c - b << "s" << endl;
system("yours.exe < data.in > yours.out");
double d = clock() / 1000.0;
cout << "[info] yours finished in " << d - c << "s" << endl;
system("type data.in"); //输出测试用例。
if (system("fc exp.out yours.out")) { //比较正解和暴力的输出一不一样。
break;
}
}
}
这里面的datamaker.cpp为数据生成器,std.cpp为暴力代码,yours.cpp就是你的正解程序。