对拍模板

发布于 2019-10-12  289 次阅读


考场不对拍,爆零两行泪。

____Payphone—X

想必大家都知道什么是对拍,我就不bb了。不会的同学右转google。

考场版

#include <bits/stdc++.h>

int main()
{
    while(1)
    {
        system("data.exe > data.in");
        system("std.exe < data.in > std.out");
        system("my.exe < data.in > my.out");
        if(system("fc my.out std.out"))
            system("pause");
    }
}

以下代码,改动了 Payphone_X 同学的代码,使测试的程序可以不用写文件输入输出,即拿即用。

对拍模板 Windows

#include<bits/stdc++.h>
#include<windows.h>

#define ll long long
#define I inline

using namespace std;

ll num , s , t;

int main(){
    while(true){
        system("cls");
        do{
            num ++;
            system("data.exe > data.txt");
            s = clock();
            system("a.exe < data.txt > std.txt");
            t = clock();
            system("b.exe < data.txt > ans.txt");
            if(system("fc std.txt ans.txt"))
                break;

            else{
                cout << "AC time" << " " << t - s << "ms" << "\n";
                cout << "This is " << num << " " << "AC" << "\n";
            }
        }while(true);
        cout << "WA time" << " " << t - s << "ms" << "\n";
        cout << "This is " << num << " " << "WA" << "\n";
        system("fc std.txt ans.txt");
        system("pause > nul");
    }
    return 0;
}

对拍模板 Linux

#include<bits/stdc++.h>

#define ll long long
#define I inline

using namespace std;

ll num , s , t;

int main(){
    while(true){
        system("clear");
        do{
            num ++;
            system("./data > data.txt");
            s = clock();
            system("./a < data.txt > std.txt");
            t = clock();
            system("./b < data.txt > ans.txt");
            if(system("diff std.txt ans.txt"))
                break;

            else{
                cout << "AC time" << " " << t - s << "ms" << "\n";
                cout << "This is " << num << " " << "AC" << "\n";
            }
        }while(true);
        cout << "WA time" << " " << t - s << "ms" << "\n";
        cout << "This is " << num << " " << "WA" << "\n";
        system("diff std.txt ans.txt");
        cout << "按任意键继续" << "\n";
        getchar();
    }
    return 0;
}