对拍器代码
#include <fstream>
void solve() {
ifstream input1;
// 你的代码运行的输出
input1.open("../output.txt");
ifstream input2;
// 正确的代码的输出
input2.open("../compare/output.txt");
int n = 10, m = 10;
int T = 10;
for (int t = 1; t <= T; t ++) {
for (int i = 1; i <= n + m + 1; i ++) {
int x, y;
input1 >> x;
input2 >> y;
if (x != y) {
cout << "WA on test" << t << " on " << i << '\n';
}
}
cout << "AC on test" << t << '\n';
}
}
随机数据生成
#include <random>
mt19937_64 rnd(1064);
int rd(int l, int r) {return rnd() % (r - l + 1) + l;}
int a[100];
void solve() {
int t = 10;
cout << t << '\n';
while (t --) {
int n = 10, m = 10;
cout << n << ' ' << m << '\n';
for (int i = 1; i <= n + m + 1; i ++) {
a[i] = rd(1, 100);
cout << a[i] << ' ';
}
cout << '\n';
for (int i = 1; i <= n + m + 1; i ++) {
int x = rd(1, 100);
while (x == a[i]) x = rd(1, 100);
cout << x << ' ';
}
cout << '\n';
}
}
以上代码均需要针对不同问题做修改。
标签:input2,10,input1,cout,int,拍器 From: https://www.cnblogs.com/lightmon5210/p/18246709