Linux系统下对拍
可以直接用C++的system函数执行对拍脚本
把造数据的mk.out文件和两个版本的代码文件放在一个文件夹下
void duipai() {
//Linux系统下可执行文件后缀为.out
while (true) {
system("./mk > data.in");
system("./zhengjie < data.in > zhengjie.out");
system("./baoli < data.in > baoli.out");
if (system("diff zhengjie.out baoli.out")) {//fc
cout << "WA" << endl;
break;
} else cout << "AC" << endl;
}
}
Linux的shell脚本
make mk
make zhengjie
make baoli
((cnt=1))
while true
do
./mk > in
./zhengjie < in > zhengjie.out
./baoli < in > baoli.out
if diff zhengjie.out baoli.out; then
printf "# $((cnt++)) Accepted\n";
else
notify-send "WA"
break
fi
done
windows
#include<bits/stdc++.h>
using namespace std;
int main()
{
while (1) //一直循环,直到找到不一样的数据
{
system("data.exe > in.txt");
system("baoli.exe < in.txt > baoli.txt");
system("std.exe < in.txt > std.txt");
if (system("fc std.txt baoli.txt")) //当 fc 返回 1 时,说明这时数据不一样
break; //不一样就跳出循环
}
return 0;
}

浙公网安备 33010602011771号