数据生成器:
#include<bits/stdc++.h>
using namespace std;
const int NMax = 10;
const int MMax = 50;
const int WMax = 1000;
int main(){
random_device rd;
srand(rd());
cout << NMax << " " << MMax << endl;
for(int i = 1; i <= NMax; i++){
cout << rand() % WMax << " ";
}
cout << endl;
int nt = 0;
for(int i = 1; i <= MMax; i++){
int opt = rand() % 10;
if(opt < 3){
int l = rand() % (NMax - 1) + 1, r = rand() % (NMax - 1) + 1;
if(l > r)swap(l, r);
cout << "C " << l << " " << r << " " << rand() % WMax << endl;
nt++;
}
else if(opt < 6){
int l = rand() % (NMax - 1) + 1, r = rand() % (NMax - 1) + 1;
if(l > r)swap(l, r);
cout << "Q " << l << " " << r << endl;
}
else if(opt < 9){
int l = rand() % (NMax - 1) + 1, r = rand() % (NMax - 1) + 1;
if(l > r)swap(l, r);
cout << "H " << l << " " << r << " " << rand() % (nt + 1) << endl;
}
else{
int tb = rand() % (nt + 1);
cout << "B " << tb << endl;
nt = tb;
}
}
return 0;
}
对拍程序 (Based on bash)
g++ (数据生成器路径) -o maker -O2 -lm -std=c++14
g++ (待测试代码路径) -o test -O2 -lm -std=c++14
g++ (暴力代码或标程路径) -o std -O2 -lm -std=c++14
for i in {1..100000};
do
./maker > ttm.in
./std < ttm.in > ttm.ans
./test < ttm.in > ttm.out
if diff ttm.out ttm.ans
then
echo "Testcase$i Accepted"
else
echo "Testcase$i Unaccepted"
exit 0
fi
done
注意补全对拍程序中各个路径
有用点个关注!