C++#include <bits/stdc++.h>
using namespace std;
int main() {
// 编译三个程序
system("g++ gen.cpp -o gen.exe -O2");
system("g++ std.cpp -o std.exe -O2");
system("g++ your_code.cpp -o your_code.exe -O2");
int cnt = 0;
while (true) {
cnt++;
// 1. 生成数据
system("gen.exe > data.in");
// 2. 标准程序跑
system("std.exe < data.in > std.out");
// 3. 你的程序跑
system("your_code.exe < data.in > your.out");
// 4. 对比结果(Windows 用 fc,Linux 用 diff)
if (system("fc std.out your.out > nul")) {
cout << "\n❌ Wrong Answer! 第 " << cnt << " 组数据出错\n";
cout << "—————— 输入数据 ——————\n";
system("type data.in");
cout << "\n—————— 标准输出 ——————\n";
system("type std.out");
cout << "\n—————— 你的输出 ——————\n";
system("type your.out");
break;
} else {
cout << "✅ Test " << cnt << " AC\n";
}
}
return 0;
}