先说随机数:
mt19937_64 eng(time(NULL));//重置种子
uniform_int_distribution<long long>ran(-10000000000,10000000000);//自行设置范围
cout<<ran(eng)<<endl;//调用随机数
C++11的随机数,比rand更好用,但相应的这个单词更难背。。(英语渣)
再说对拍:
#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<cassert>
#include<bitset>
#include<unordered_map>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf=0x3f3f3f3f;
const int N=2e5+100;
int main()
{
#ifndef ONLINE_JUDGE
// freopen("data.in.txt","r",stdin);
// freopen("data.out.txt","w",stdout);
#endif
// ios::sync_with_stdio(false);
for(int i=1;i<=10000;i++)//样例组数
{
system("random.exe");//先生成随机数到data.in
double st=clock();
system("未命名1.exe");//调用自己的错误程序:data.in->data.out
double ed=clock();
system("未命名2.exe");//调用自己的正确程序(暴力):data.in->data.ans
if(system("fc data.out.txt data.ans.txt"))//判断data.out和data.ans是否一致
{
puts("Wrong Answer");
return 0;
}
else
printf("Accepted, 测试点 #%d, 用时 %.0lfms\n",i,ed-st);
}
return 0;
}
未命名一中加上:
freopen("data.in.txt","r",stdin);
freopen("data.out.txt","w",stdout);
未命名二中加上:
freopen("data.in.txt","r",stdin);
freopen("data.ans.txt","w",stdout);
随机数中加上:
freopen("data.in.txt","w",stdout);
以上操作皆用于程序与文件的互动