对拍代码
#include<bits/stdc++.h>
using namespace std;
const int N=2023;
int n,m,Test_number,Time_limit;
int main(){
cin>>Test_number;//对拍组数
cin>>Time_limit;//时限
printf("Test number:%d\n",Test_number);
printf("Time limit:%dms\n",Time_limit);
system("g++ a.cpp -o a -O2 -std=c++14 -Wl,-stack=998244353");//暴力代码a
system("g++ data.cpp -o data -O2 -std=c++14 -Wl,-stack=998244353");//随机数据data
system("g++ std.cpp -o std -O2 -std=c++14 -Wl,-stack=998244353");//正解代码std
printf("compile completed\n\n");
for(int i=1;i<=Test_number;i++){
system("data.exe>a.in");
system("std.exe<a.in>a.ans");
n=clock();
printf("Test %d: ",i);
if(system("a.exe<a.in>a.out"))return printf("RE"),0;
n=clock()-n;
if(system("fc a.out a.ans>c.out"))
return printf("WA\n",n),0;
else if(n>=Time_limit)return printf("TLE(%dms)\n",n),0;
else printf("AC(%dms)\n",n),m++;
}
printf("%.0lf%",100.0*m/Test_number);
return 0;
}随机数据代码
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+2;
int n,q,x,a[N],b[N];
mt19937 rnd(time(0));
int rand(int l,int r){return l+rnd()%(r-l+1);}
int main(){
n=1e5,srand(time(0));
printf("%d %d %d\n",n,x=rand(1,n-1),rand(x,n-1));
for(int i=2;i<=n;i++)
printf("%d %d %d\n",i,rand(1,i-1),rand(1,1e6));
return 0;
}