如何比较自己答案和大样例答案是否一致

学术版

c_y_y @ 2024-10-13 14:37:43

rt,bdfs 无果


by fp0cy1tz6mn4rd_ @ 2024-10-13 14:38:58

@c_y_y diff file1 file2(应该是


by wangcaizsr @ 2024-10-13 14:40:03

自己写个程序呗 @c_y_y


by wangyishan @ 2024-10-13 14:40:32

Windows : fc

Linux : diff

@c_y_y


by wjh2022 @ 2024-10-13 14:49:15

@c_y_y

#include <bits/stdc++.h>
using namespace std;

signed main() {
    system("fc xxx.ans xxx.out");
    return 0;
}

by DGFLSzfd @ 2024-10-13 14:49:37

@c_y_y this当然这个工具考试的时候用不了,平常比赛练习还是可以


by wjh2022 @ 2024-10-13 14:50:02

@wjh2022 这个应该只能在 windows 下用(


by jason_sun @ 2024-10-13 14:55:22

可以直接用c++写的,用不着bat


by liujinxv123 @ 2024-10-13 14:56:49

写个程序对比呗。 例子: 自己程序的输出在xxx.out内,标准答案在xxx.ans内。则:

freopen("xxx.out","r",stdin);
for(int i = 1;i <= n;i ++) cin >> a[i];
freopen("xxx.ans","r",stdin);
for(int i = 1;i <= n;i ++) cin >> b[i];
for(int i = 1;i <= n;i ++){
  if(a[i] != b[i]){
    cout << "N";
    return 0;
   }
}

by VoId_D_C @ 2024-10-13 15:16:35

你搜一下对拍,不止可以比对大样例,还可以生成样例比对暴力代码的结果和自己写的“正解”是否一致,挺好用的


by VoId_D_C @ 2024-10-13 15:18:26

@wjh2022 这个是windows.h库里的,考试测完一定要删(别问我怎么知道的)


| 下一页