赛时样例太少或太弱怎么办,这时就需要对拍程序了。 它也可以用来hack或验证正确性。
对拍时我们需要四个程序,分别是:
- random.cpp(生成数据)
模板code:
#include<bits/stdc++.h>
using namespace std;
//mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());质量高但难记
mt19937_64 rd(time(0));//方便直接
signed main(){
freopen("_test.in","w",stdout);
ios::sync_with_stdio(0);
cout.tie(0);
int n=rd()%10;//%来保证数据范围,较小的数据方便自己改
/*
根据题目来输出测试数据
*/
return 0;
}- baoli.cpp(暴力代码)
#include<bits/stdc++.h>
using namespace std;
signed main(){
freopen("_test.in","r",stdin);
freopen("baoli.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
//...
return 0;
}- solve.cpp(需调试的代码)
#include<bits/stdc++.h>
using namespace std;
signed main(){
freopen("_test.in","r",stdin);
freopen("solve.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
//...
return 0;
}- duipai.cpp(对拍代码)
#include<bits/stdc++.h>
using namespace std;
signed main(){
while(1){
system("random.exe");//运行数据程序
system("baoli.exe");//运行暴力程序
system("solve.exe");//运行调试程序
if(system("fc /n baoli.out solve.out")){
cout<<"WA";
getchar();//暂停
}//fc 对比输出数据的区别 /n 输出不一样的行号
}
return 0;
}