对拍

  学习了对拍,主要总结一下该咋么写,针对本人,出现了以下几点问题。

1.4个程序的文件名一定要起好,以后要固定分别为bf(暴力)brutal force 、sol(solution)、pai(对拍的程序)、random(随机数据的产生)。

2.然后是bf和sol的输入和输出位置的所在地。都为

       freopen("data.in","r",stdin);
       freopen("data.out","w",stdout);//sol
       freopn("data.ans","w",stdout);//bf

输出的位置要不同不然如何找输出,然后就是得到的输入文件的位置要一致。

至于random的输出文件就要和上面的相吻合了。

    freopen("data.in","w",stdout);

向这个in之中输入文件,两个程序就可能得到输出。

然后关键就是对拍文件了这个一般都是有固定格式的,针对本人电脑这4个cpp要放到文件夹之中不能直接放在某个盘的根目录下,要不然无法编译,mgw无法编译,dev编译出来的东西无法运行,然后就是只能用GDB编译,不用set path 学长搞得,导致本人不会。用gdb编译好像直接在某个盘的根目录下是无法编译的,所以此时应放在一个盘内的文件夹内再进行编译即可。

固定的格式:

#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<cstdlib>
using namespace std;
int main()
{
    for(int t=1;t<=1000;t++)
    {
        system("C:\random.exe");
        double st=clock();
        system("C:\sol.exe");
        double ed=clock();
        system("C:\bf.exe");
        if(system("fc C:\data.out C:\data.ans"))
        {
            puts("Wrong Answer");
            return 0;
        }
        else
        {
            printf("Accepted,测试点 #%d,用时 %.0lfms
",t,ed-st);
        }
    }
}

当然这是标准格式真正的代码是这几个exe真正的所在位置,输出位置是值得注意的是\单有warnings

尽量严谨一点。对拍就搞好了!

原文地址:https://www.cnblogs.com/chdy/p/10148822.html