跳到正文

个人记录

对拍指南

HACKILLER约 5 分钟
原文
文章信息与版本

文章信息

收录
2026年6月27日
更新
2026年8月2日
篇幅
约 5 分钟

版本

  1. v1当前

对拍需要同一个文件夹下的 44 个文件,它们分别是:

  • 你的正解(std.cpp)
  • 你的暴力代码(bf.cpp)
  • 数据生成器(gen.cpp)
  • 对拍代码(paizi.cpp)

举个例子:

正解代码
C++
#include<bits/stdc++.h>
//Things will always be better, just let time play
using namespace std;
#define HACKILLER_JBLX ios::sync_with_stdio(false),cin.tie(0)
//#define int long long
#define ull unsigned long long
#define rint register int
#define db double
#define pii pair<int,int>
#define vc vector
#define pb push_back
#define ls x<<1
#define rs x<<1|1

signed main(){
	freopen("data.in","r",stdin);
	freopen("task.out","w",stdout);
	HACKILLER_JBLX;
	//你的正解
	return 0;
}
暴力代码
C++
#include<bits/stdc++.h>
//Things will always be better, just let time play
using namespace std;
#define HACKILLER_JBLX ios::sync_with_stdio(false),cin.tie(0)
//#define int long long
#define ull unsigned long long
#define rint register int
#define db double
#define pii pair<int,int>
#define vc vector
#define pb push_back
#define ls x<<1
#define rs x<<1|1

signed main(){
	freopen("data.in","r",stdin);
	freopen("bf.out","w",stdout);
	HACKILLER_JBLX;
	//你的暴力
	return 0;
}
数据生成器
C++
#include<bits/stdc++.h>
//Things will always be better, just let time play
using namespace std;
#define HACKILLER_JBLX ios::sync_with_stdio(false),cin.tie(0)
//#define int long long
#define ull unsigned long long
#define rint register int
#define db double
#define pii pair<int,int>
#define vc vector
#define pb push_back
#define ls x<<1
#define rs x<<1|1

inline int randint(int l,int r){ //表示生成范围在[l,r]之间的随机数
	int x = (rand()<<16LL)|rand();
	return x%(r-l+1)+l;
}

int main(){
	srand(time(0) ^ (unsigned long long) new char);
	freopen("data.in","w",stdout); //将输出的数存在 data.in 文件里,方便对拍代码运行
	HACKILLER_JBLX;
	return 0;
}
对拍代码
C++
#include<bits/stdc++.h>
//Things will always be better, just let time play
using namespace std;
#define HACKILLER_JBLX ios::sync_with_stdio(false),cin.tie(0)
//#define int long long
#define ull unsigned long long
#define rint register int
#define db double
#define pii pair<int,int>
#define vc vector
#define pb push_back
#define ls x<<1
#define rs x<<1|1

int main(){
	int cnt = 0;
	while(1){
		printf("cnt = %d\n", ++cnt);
		system("gen.exe");
		system("bf.exe");
		system("task.exe");
		if(system("fc bf.out task.out")) break;
	}
	return 0;
}

需要注意的是正解代码和暴力代码应当在文件输入输出部分出现的不同。每次运行对拍代码前,应将最新的正解代码、暴力代码、数据生成器都编译一遍。

原文