[C++] 对拍模板

共需内容:

  • create.exe 数据生成器
  • match.exe 匹配程序
  • check.exe 正解
  • test.exe 测试程序

以 A+B Problem 为例示范:

create.cpp

#include<bits/stdc++.h>
using namespace std;
#define rand(a,b) rand()%((b)-(a)+1)+(a)
int main(){
	struct _timeb T;
	_ftime(&T);
	srand(T.millitm);
	cout<<rand(1,32767)<<" "<<rand(1,32767);
}

match.cpp

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
	cout<<"Test number >>";
	int cases;
	int tl;
	cin>>cases;
	cout<<"Time Limit (ms) >>";
	cin>>tl;
	int cr=0;
	for(int c=1;c<=cases;++c){
		cout<<"Test "<<c<<endl;
		system("create.exe > test.txt");
		system("check.exe < test.txt > check.txt");
		int start=clock();
		system("test.exe < test.txt > answer.txt");
		int end=clock();
		cout<<"Finished in "<<end-start<<" ms."<<endl;
		if(system("fc check.txt answer.txt")){
			cout<<"Wrong Answer"<<endl;
			system("pause");
		}
		else if(end-start>tl){
			cout<<"TimeLimitedExceed"<<endl;
			system("pause");
		}
		else{
			cout<<"Accept"<<endl;
			cr++;
		}
		cout<<endl<<endl<<endl;
	}
	cout<<"Test Over"<<endl;
	cout<<"Total correct : "<<cr<<" / "<<cases<<endl;
	system("pause");
}
posted @   HaneDaniko  阅读(25)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示