对拍
对拍
对拍是常用的暴力寻找算法边界条件的工具
要使用对拍,我们要准备四个文件,依次是对拍工具duipai.cpp,数据生成工具data.cpp,正确的代码std.cpp,待测试的代码test.cpp,将后三个cpp文件编译以后,再运行duipai工具。
#include <bits/stdc++.h>
using namespace std;
int main() {
int t = 100; //测试的次数
while (t--) {
system("data > case.in");
system("std < case.in > std.out");
system("test < case.in > test.out");
if (system("fc std.out test.out")) break;
}
if (t > 0) {
cout << "Wrong Answer on case.in" << endl;
}
return 0;
}