对拍板子

发布时间 2023-04-04 11:59:22作者: whoamiiii

以防忘记
三个cpp文件 a.cpp表示待拍文件, b.cpp表示暴力版本,data.txt表示生成的数据。

#include <bits/stdc++.h>

using namespace std;

void generateData(){
    ofstream fout("input.txt");
    for(int i = 0; i < 10; i++){
        int a = rand() % 10 + 10; //[10, 20)
        int b = rand() % 10 + 5;  //[5, 15)
         fout << a << ' '<< b << endl;
    }
}

int main(){
    for(int round = 1; round <= 100; round++){
        generateData();
        system("a.exe < input.txt > a_output.txt");
        system("b.exe < input.txt > b_output.txt");
        if (system("fc a_output.txt b_output.txt")){
            puts("Wrong Answer!");
            break;
        }
    }
}

一旦出现Wrong Answer,就说明input.txt那组数据可以让a.cpp出错。