对拍
https://www.cnblogs.com/light-house/p/11759894.html
https://blog.csdn.net/ModestCoder_/article/details/90107874
太区区
首先需要写一个自己认为对的和一个暴力
然后您需要一个数据生成器
代码在下面:
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;
int random(int n){
return (ll)rand() * rand() % n;
}
int main(){
int a[10001];
srand((unsigned)time(0));
int n=random(100000)+1;//随机生成<=1e5个绝对值在1e9以内的整数
int m=1000000000;
for(int i=1;i<=n;i++)
{
a[i]=random(2 * m + 1) - m ;
printf("%d ",&a[i]);
}
//可以再random_shuffle一下
// srand((unsigned)time(NULL));
// for(int i=1;i<=100;i++)
// {
// int a= random(99435323)+rand();
// int b= random(20040712)+rand();
// printf("%d %d ",&a,&b); }
}
然后需要写一个对拍程序
#include<cstdio>
#include<windows.h>
#include<ctime>
using namespace std;
int main(){
int t=100;
for(int i=1;i<=t;i++){
system("data>a+b.txt");
system("force<a+b.txt>force.txt");
double t1 = clock();
system("force2<a+b.txt>force2.txt");
double t2 = clock();
if(system("fc force.txt force2.txt")) {
puts("WRONG");
return 0;
}
else printf("%d time %lf ",i,t2 - t1);
}
return 0;
}
记住要自己开两个exe文件和txt文件
好了,然后就可以愉快的爆零了
@echo off
:go
data.py > in.txt
1.exe < in.txt > out.txt
std.exe < in.txt > ans.txt
fc out.txt ans.txt
if not errorlevel 1 goto go
pause