在考场上你不能肯定自己的代码正确,你可以写一个暴力程序,与你的代码进行对拍,以验证你的代码的正确性。(显然暴力程序不能写错)
怎么对拍1.首先,你要将你准备提交评测的程序,名为sol.cpp。将改程序从cin.in中读取输入数据,并将答案输出到sol.out中
2.准备你的暴力的程序,名为bf.cpp。将改程序从cin.in中读取输入数据,并将答案输出到bf.out中
3.写一个随机生成程序的代码,名为make.cpp,将随机数据输出到cin.in中。
4.你现在要写一个脚本,循环运行:运行make.exe,运行sol.exe,运行bf.exe,比对sol.out,bf.out的内容是否一致
#include#define LL long long #define PP pair using namespace std; int main () { ios::sync_with_stdio (false); cin.tie (0), cout.tie (0); srand (time (0)); int ans = 0; for (int i = 1; i <= 10000; i ++ ) { system ("D:\make.exe"); double st = clock (); system ("D:\test.exe"); double en = clock (); system ("D:\BF.exe"); if (system ("fc D:\BF.out D:\test.out")) { cout << "WA" << endl; return 0; } else printf ("AC, 测试点 #%d, 用时 %.0lfmsn", i, en - st); } return 0; } //这里所有代码存在D盘,要注意地址的正确



