跳到正文

个人记录

对拍

tujiaqi12约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年5月23日
收录
2026年10月4日
更新
2026年11月19日
篇幅
约 2 分钟

版本

  1. v1当前
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;
}
原文