Windows 对拍模板

· · 个人记录

适用系统:Windows

Linux、Mac 对拍模板(链接已修正)

准备工作

random.cpp(随机数据生成程序)

random.cpp 需使用以下模板(输出文件名可随意更改,注意 Windows 系统下 rand() 函数的范围是 0~32767):

#include <bits/stdc++.h>
using namespace std;
long long random(int l, int r) {    //生成[l,r]之间的随机数
    return rand() * rand() % (r - l + 1) + l;
}
int main() {
    freopen("test.in", "w", stdout);
    srand((unsigned)time(NULL));
    //Your code here...
    return 0;
}

sol.cpp(需要对拍的程序)

sol.cpp 需使用以下模板(输入/输出文件名可随意更改):

#include <bits/stdc++.h>
using namespace std;
int main() {
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
    //Your code here...
    return 0;
}

bf.cpp(朴素算法程序/正解生成程序)

bf.cpp 需使用以下模板(输入/输出文件名可随意更改):

#include <bits/stdc++.h>
using namespace std;
int main() {
    freopen("test.in", "r", stdin);
    freopen("test.ans", "w", stdout);
    //Your code here...
    return 0;
}

重要提示:以上三个程序需要编译并得到运行程序文件

代码模板

#include <bits/stdc++.h>
#define N 1000 //对拍的数据组数,可根据需要自行修改
using namespace std;
int main() {
    for (int T = 1; T <= 1000; T++) {
        system("random.exe");
        double st = clock();
        system("sol.exe");
        double ed = clock();
        system("bf.exe");
        if (system("fc /W /N test.out test.ans")) {
            //测试点 #T 出现答案错误,留存的 test.in、test.out 和 test.ans 均为出现错误的测试数据
            cout << '#' << T << " WA " << ed - st << "ms\n";
            return 0;
        }
        else    cout << '#' << T << " AC " << ed - st << "ms\n";
        cout << "-------------------------\n";
    }
    cout << "All right.\n"; //全部正确
    return 0;
}