前言
为什么要写这么一个东西呢?
突发奇想?其实也只是为了自己方便。
我也不是自私的人,想把这些东西分享给广大谷民,于是开始着手打包。
想了又想,改了无数个新式,最终确定以头文件的形式表现出来。
你现在看见的,只不过是一个蒟蒻的脑洞大开,如有不足,可以指明更正;如果你不喜欢,就当看个乐子。
食用说明
这是头文件的介绍,当然您也可以在头文件中看到:
/*
本头文件采用 UTF-8 格式进行编码,如出现中文乱码请检查编辑器编码格式。
应在 windows10 C++14 环境下使用该头文件。
本头文件作者为 LZYXT https://www.luogu.com.cn/user/2028864
头文件使用教程 https://www.luogu.com.cn/article/ned9ze68
头文件名称为 duipai.hpp
但其并不是只能对拍。
这里面打包了绝大部分OI中常用的工具,希望可以为您带来便利。
为什么要将其命名为 duipai.hpp ?
我想,这是一个工具头文件,就要体现出其工具的性质。
以对拍命名既可以体现出其工具的性质,也可以体现出其强大的特点?(雾
难道就不能是作者想不到更好的名字了吗?
头文件持续更新中,相关建议可以私信。
*/完整 并不完整 头文件放在了文章末尾,有需要的话可以自取。
下面我会先讲一些主要功能。
准备
开始
当然要先引入这个头文件,然后在主函数第一行写上 Start();,最后一行写上 exitcode(0)
#include "duipai.hpp"
signed main(int argc,char* argv[]){
Start();
exitcode(0);
}-
Start();目前只有一个作用,那就是将控制台的编码格式改为 UTF-8,以与编辑器适配,防止出现中文乱码。 -
exitcode(0);作用类似于exit(0),不过exitcode(0)更加适配。-
若
exitcode(-1,string)则会在控制台输出一个红色的错误字样,并在之后输出字符串中的内容。 -
若
exitcode(not -1,string)则只会输出字符串中的内容。 -
注意:
exitcode(num)会立刻终止程序,这一点参考exit(num)。
-
行为
在命名空间 namespace behavior 中可以对程序的行为进行调整。
-
bool pause=0;当其值为true时,程序在使用exitcode函数退出之前,会运行一次system("pause"),即暂停程序。 -
bool log=0;当其值为true时,使用addlog(string s,string t)函数会将字符串s输出到日志文件中。 -
bool process=0;当其值为true时,使用addlog(string s,string t)函数会将字符串t输出到控制台中。 -
string compile="-std=c++14 -O2";当需要编译其他程序时,会添加次命令。 -
string chcp="65001";控制台的编码格式,65001为 UTF-8 编码。 -
ofstream logout("tls.log",ios::app);日志文件的输出流。
带颜色输出
使用函数 printc(string,color) 可输出带颜色的字体,具体实现为 WINAPI。
颜色参数如下:
-
白色:_WHITE
-
红色:_RED
-
绿色:_GREEN
-
黄色:_YRLLOW
-
紫色:_PURPLE
其他
在头文件中已经定义了:
typedef unsigned long long ull;
typedef long long ll;对拍启动器
既然名字都叫对拍了,那肯定是能对拍的啊。
什么是启动器?就是你写对拍的时候启用对拍的那个程序,各自有各自的叫法,但我喜欢叫它启动器。
初始化
首先在主函数第二行写上 InitLuncher(argc,argv); 其中 argc,argv 为命令行参数。
这个函数的作用是初始化启动器并解析命令行参数。
#include "duipai.hpp"
signed main(int argc,char* argv[]){
Start();
InitLuncher(argc,argv);
exitcode(0);
}我说这个初始化是借鉴的 testlib 有没有懂的。
启动一次对拍
使用函数 LUNCHRES Lunch(int timlim,vector<string> argvs) 可以启动一次对拍,并将对拍结果以 struct LUNCHRES 的形式返回。
关于传参
不会用?我还没说完:
-
参数
int timlim,表示允许程序运行的最大时间,单位毫秒,仅待测程序和正确程序受此影响。 -
参数
vector<string> argvs表示传给每一个程序的命令行参数,必须传入恰好 个,参数对应关系为:<数据生成器> <答案校验器> <待测程序> <正确程序>
下面请看实例:
#include "duipai.hpp"
signed main(int argc,char* argv[]){
Start();
InitLuncher(argc,argv);
auto res=Lunch(1000,{
"> data.in",
"data.out data.ans",
"< data.in > data.out",
"< data.in > data.ans"
});
exitcode(0);
}如此,假设数据生成器为 gen.exe,答案校验器为 fc,待测程序为 tst.exe,正确程序为 cur.exe。
程序会依次运行以下命令:
-
gen.exe > data.out -
cur.exe < data.in > data.ans -
tst.exe < data.in > data.out -
fc data.out data.ans
关于返回值
返回值类型为 struct LUNCHRES,其成员函数,变量如下:
-
int res表示对拍的评测结果。 -
int returned表示待测程序的返回值。 -
clock_t runtime待测程序运行时间。 -
bool AC()判断结果是否为AC。bool TLE()、bool RE()、bool WA()同理。 -
bool operator == (const int oth)判断结果是否为oth,其中oth可以为_AC、_PE、_WA、_RE、_TLE。
判断对拍结果
当然,您可以调用 struct LUNCHRES 中的成员函数、变量进行判断,但我贴心地为大家准备了一个判断函数 void judgment(LUNCHRES res),只需要将对拍的结果穿进去,函数就可以自行判断了!
该函数具体实现如下:
void judgment(LUNCHRES res){ //判断对拍结果
if(res.AC()) printc("AC ",_GREEN);
if(res.WA()) printc("WA ",_RED);
if(res.TLE()) printc("TLE ",_PURPLE);
if(res.RE()) printc("RE "+to_string(res.returned)+' ',_YELLOW);
std::cout<<(double)res.runtime/CLOCKS_PER_SEC<<" s"<<endl;
if(!res.AC()) exitcode(1,"对拍出现错误,程序退出。");
}使用/命令行参数
前 个参数必须依次是 <数据生成器> <答案校验器> <待测程序> <正确程序> 然后就可以穿一些其他的参数了:
-
-pause将behavior::pause的值改为 true。 -
-process、-log同上 -
-compile后接具体的编译参数,修改behavior::compile的值。实例:-compile "-std=c++14 -O2 -Wall -lm"记住要加引号。
如果 <数据生成器> <答案校验器> <待测程序> <正确程序> 中存在以 .cpp 结尾的文件,该函数会尝试进行编译,编译参数为 behavior::compile。
如果你不想写一个答案校验器,也就是 checker,您可以在答案校验器的位置写上 fc,即用系统自带的 fc 进行比较。
同时,如果有其他语言的文件,如 Python 文件,可以通过命令行直接运行的,理论上都可以传入。
对拍启动器模板
#include "duipai.hpp"
signed main(int argc,char* argv[]){
Start();
InitLuncher(argc,argv);
while(1){
auto res=Lunch(1000,{
"> data.in",
"data.out data.ans",
"< data.in > data.out",
"< data.in > data.ans"
});
judgment(res);
}
exitcode(0);
}十分小巧。
随机数生成
头文件中有一个 class RandGen 可以用来生成随机数,内部基于 mt19937 实现,用法与 mt19937 一致,唯一不同的就是 RandGen 可以以字符串作为种子:
RandGen rnd("LZYXT") //合法可使用 () 获取一次随机 unsigned long long 类型的整数。
rnd() //获取一个随机ull整数如果只有一个随机数生成器也没有什么可耀武扬威的,主要是下面要介绍的东西。
生成相关函数
不是生成函数!!!
这些函数主要是用来生成一些东西的。好像说了又没说?
以下函数存在于 namespace GenSpace 中。
有序生成
alist 生成一个有序数列
- 使用
alist(start,end,step)可以生成一个从start到end(两边都取)差值为step的等差数列,返回一个vector。
vector<int> a=alist(1,10,1); //a={1,2,3,4,5,6,7,8,9,10}
vector<int> b=alist(10,1,-1); //b={10,9,8,7,6,5,4,3,2,1}
vector<double> c=alist(0.0,1.0,0.1) //c={0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}- 使用
alist(start,end,nxt,chk)生成有特定顺序的序列,其中nxt、end为函数,nxt传入一个参数,返回这个值的下一个值,check传入当前值与end判断是否继续生成。
vector<int> a=alist(1,100,[](int x){return x+(x&-x);},[](int x,int y){return x<=y;});
//a={1,2,4,8,16,32,64}
vector<pair<int,int>> a=alist<pair<int,int>>(
{1,2},
{5,10},
[](pair<int,int> x){return (pair<int,int>){x.first+1,x.second+2};},
[](pair<int,int> x,pair<int,int> y){return x.first<=y.first;}
);
//a={{1,2},{2,4},{3,6},{4,8},{9,10}}astr 生成有序字符串
目前只支持类似 alist(start,end,step) 的生成方式。
string s=alist('a','g',1); //s="abcdefg"
string s=alist('g','a',-2); //s="geca"随机生成
在 namespace GenSpace 中,有一个默认的随机数生成器 RandGen _rand(0)。
rint 生成随机整数
这里的整数包括 int、unsigned int、long long、unsigned long long、char、unsigned char 等。
使用 rint(l,r,RandGen) 生成在区间 中的随机整数,其中 RandGen 默认为 _rand。
int a=rint(1,10) //1 到 10 的随机整数。
char b=rint('a','z') //a 到 z 的随机字符。real 生成随机实数
使用 real(1,r,precision,RandGen) 生成在区间 的随机实数,分度值为 precision 默认 ,RandGen 同上。
关于精度值:
- 并不是小数点后几位,而是将区间 分成
precision份,每次随机取一个分界线。
double a=real(0.0,1.0) //[0,1]随机小数
int b=real(0,10,5) //b 的值域集合 {0,2,4,6,8,10}rstr 生成随机字符串
使用 rstr(len,l,r,RandGen) 生成由区间 组成的长度为 len 的字符串。
rilist 生成随机整数序列
使用 rilist(len,l,r,RandGen) 生成由区间 组成的长度为 len 的整数序列,返回值为 vector。
rrlist 生成随机实数序列
使用 rrlist(len,l,r,precision,RandGen) 生成由区间 组成的长度为 len 精度值为 precision 的实数序列,返回值为 vector。
头文件
头文件
/*
本头文件采用 UTF-8 格式进行编码,如出现中文乱码请检查编辑器编码格式。
应在 windows10 C++14 环境下使用该头文件。
本头文件作者为 LZYXT https://www.luogu.com.cn/user/2028864
头文件使用教程 https://www.luogu.com.cn/article/ned9ze68
头文件名称为 duipai.hpp
但其并不是只能对拍。
这里面打包了绝大部分OI中常用的工具,希望可以为您带来便利。
为什么要将其命名为 duipai.hpp ?
我想,这是一个工具头文件,就要体现出其工具的性质。
以对拍命名既可以体现出其工具的性质,也可以体现出其强大的特点?(雾
难道就不能是作者想不到更好的名字了吗?
头文件持续更新中,相关建议可以私信
为防止中文出现乱码导致不可读,头文件介绍有英文的翻译版本:
This header file is encoded in UTF-8. If you see garbled Chinese, please check your editor's encoding.
This header file should be used in a Windows10 C++14 environment.
The author of this header file is LZYXT https://www.luogu.com.cn/user/2028864
Header file usage guide https://www.luogu.com.cn/article/ned9ze68
The header file is named duipai.hpp
But it's not just for comparison testing.
It contains most commonly used tools in OI, hoping to bring you convenience.
Why name it duipai.hpp?
I think, since it is a tool header file, it should reflect its nature as a tool.
Naming it after comparison testing both reflects its tool nature and its powerful features? (just joking
Could it be that the author just can't think of a better name?
The header file is continuously updated, and suggestions can be sent via private message
*/
#define DUIPAI
#ifdef DUIPAI
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
namespace behavior{ //行为
bool pause=0; //是否在结束之前暂停
bool log=0; //是否输出日志
bool process=0; //是否输出进程
string compile="-std=c++14 -O2"; //编译命令
string chcp="65001";
ofstream logout("tls.log",ios::app);
}
void addlog(string s,string t){ //写入日志/输出进程
if(behavior::process&&t!="") std::cout<<t<<endl;
if(!behavior::log||s=="") return;
SYSTEMTIME T;
GetLocalTime(&T);
behavior::logout<<T.wYear<<'/'<<T.wMonth<<'/'<<T.wDay<<' '<<T.wHour<<':'<<T.wMinute<<':'<<T.wSecond<<':'<<T.wMilliseconds<<' ';
behavior::logout<<s<<endl;
}
#define _WHITE 7
#define _GREEN 10
#define _RED 12
#define _YELLOW 14
#define _PURPLE 13
void printc(string s, int color=7){ //带颜色的输出
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
addlog("output: "+s+" with color "+to_string(color),"");
std::cout<<s;
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
void end(int exitnum){ //退出程序
addlog("Program exited with code "+to_string(exitnum),"程序退出,退出码 "+to_string(exitnum));
exit(exitnum);
}
void exitcode(int exitnum,string s=""){ //退出程序并输出
if(exitnum==-1) printc("错误 ",12);
if(s!="") std::cout<<s<<'\n';
if(behavior::pause) system("pause");
end(exitnum);
}
namespace RunSpace{ //子进程运行空间
string name,argv;
clock_t st=0,ed=0;
int returned=0;
DWORD WINAPI TestedProgram(LPVOID lpParameter){
st=clock();
returned=system((name+' '+argv).c_str());
ed=clock();
return 0;
}
}
namespace ResSpace{
struct RES{ // 用于存一个程序的运行结果
DWORD waitres; //等待结果
int prores; //返回值
clock_t runtime;//运行时间
};
ostream& operator<<(ostream& out,const RES x){
out<<x.waitres<<' '<<x.prores<<' '<<x.runtime<<'\n';
return out;
}
}
class program{
string name;
public:
program(string s,string compile=behavior::compile){
if(s.rfind(".cpp")!=string::npos){//检查是否为.cpp文件
s.erase(s.rfind(".cpp"));
addlog("Compiling: "+s+".cpp","正在编译:"+s+".cpp 编译命令:"+compile);
if(system(("g++ -o "+s+".exe "+s+".cpp "+compile).c_str())){//无法编译
exitcode(-1,"无法编译 "+s+".cpp");
}
addlog(s+".cpp Compiled successfully",s+".cpp 编译成功");
name=s+".exe";
}else name=s;
}
ResSpace::RES Run(int tim=1000,string argv=""){//运行程序
if(name=="null") return {(DWORD)-1,0,0};
addlog("Running: "+name,"正在运行:"+name);
RunSpace::name=name;//更改程序名
RunSpace::argv=argv;//更改参数
HANDLE hThread;
hThread=CreateThread(NULL,0,RunSpace::TestedProgram,NULL,0,NULL); //获得控制台句柄
if(hThread==NULL) return {(DWORD)-1,-1,(clock_t)-1};
DWORD waitres=WaitForSingleObject(hThread,tim==-1?INFINITE:tim); //运行并等待超时或程序结束
if(waitres){
addlog("The program has timed out,trying to end the process.","程序运行超时,正在尝试结束进程");
system(("taskkill /f /im "+name).c_str());
WaitForSingleObject(hThread,5000); //等待线程真正退出,避免与下一轮 Run 竞争 RunSpace
}
CloseHandle(hThread);
return (ResSpace::RES){waitres,RunSpace::returned,RunSpace::ed-RunSpace::st};
}
}gen(""),chk(""),tst(""),cur("");
void InitLuncher(int argc,char* argv[]){ //初始化程序为启动器并解析命令行参数
if(argc<5) exitcode(-1,"参数过少,请按照以下方式传入命令行参数:<数据生成器> <答案校验器> <待测程序> <正确程序> <其他>");
for(int i=5;i<argc;++i){//遍历命令行参数
string arg=argv[i];
if(arg=="-pause"){
behavior::pause=1;
}else if(arg=="-log"){
behavior::log=1;
}else if(arg=="-process"){
behavior::process=1;
}else if(arg=="-compile"){
++i;
if(i==argc) exitcode(-1,"没有传入编译命令");
arg=argv[i];
behavior::compile=arg;
}else{
exitcode(-1,"没有与其匹配的命令:"+arg);
}
}
gen=program(argv[1]); //初始化程序
chk=program(argv[2]);
tst=program(argv[3]);
cur=program(argv[4]);
signal(SIGINT,end); //初始化退出程序
addlog("Launcher initialized successfully.","启动器初始化成功!");
}
const int _AC=0;
const int _WA=1;
const int _PE=2;
const int _RE=3;
const int _TLE=4;
struct LUNCHRES{ //用于存对拍的结果
int res,returned;
clock_t runtime;
bool operator == (const int oth){
return res==oth;
}
bool AC(){return res==_AC;};
bool RE(){return res==_RE;};
bool TLE(){return res==_TLE;};
bool WA(){return res==_WA;};
};
LUNCHRES Lunch(int timlim,vector<string> argvs){ //启动一次对拍,timlim:时间限制;argvs 对于每一个程序的命令行参数。
if(argvs.size()!=4) exitcode(-1,"参数串数不匹配,请传入恰好 4 个参数串");
ResSpace::RES res,tmpres;
tmpres=gen.Run(-1,argvs[0]);//运行生成器
if(tmpres.waitres!=0) exitcode(-1,"数据生成器 "+RunSpace::name+" 运行失败");
if(tmpres.prores!=0) exitcode(-1,"数据生成器 "+RunSpace::name+" 的返回值不为零:"+to_string(tmpres.prores));
tmpres=cur.Run(timlim,argvs[3]); //运行正确程序
if(tmpres.waitres==WAIT_TIMEOUT) exitcode(-1,"程序 "+RunSpace::name+"运行超时");
if(tmpres.prores) exitcode(-1,"程序 "+RunSpace::name+" 的返回值不为零:"+to_string(tmpres.prores));
res=tst.Run(timlim,argvs[2]); //运行待测程序
if(res.waitres==WAIT_TIMEOUT) return {_TLE,0,0};
if(res.prores) return {_RE,res.prores,res.runtime};
tmpres=chk.Run(-1,argvs[1]); //运行答案校验器
if(tmpres.waitres!=0) exitcode(-1,"答案校验器 "+RunSpace::name+" 运行失败");
if(tmpres.prores!=_WA&&tmpres.prores!=_PE&&tmpres.prores!=_AC){
exitcode(-1,"无法识别答案校验器的返回值:"+to_string(tmpres.prores));
}
if(tmpres.prores==_AC) return {_AC,res.prores,res.runtime};
return {_WA,res.prores,res.runtime};
}
void judgment(LUNCHRES res){ //判断对拍结果
if(res.AC()) printc("AC ",_GREEN);
if(res.WA()) printc("WA ",_RED);
if(res.TLE()) printc("TLE ",_PURPLE);
if(res.RE()) printc("RE "+to_string(res.returned)+' ',_YELLOW);
std::cout<<(double)res.runtime/CLOCKS_PER_SEC<<" s"<<endl;
if(!res.AC()) exitcode(1,"对拍出现错误,程序退出。");
}
class RandGen{//随机数生成器
ull key1=0x1234567890abcdefull;
ull key2=0xabcdef1234567890ull;
void shift1(){
key1<<=2;
key1^=0x1a2b3c4d5e6f7890ull^(key2<<5);
key2>>=3;
key2^=0xf6e5d4c3b2a10987ull^(key1>>7);
}
void shift2(ull x){
key1*=x^0x190293ull;
key1+=0x189283819283928ull+key2;
key2*=x^0x819283ull;
key2+=0x3f7f77298192839ull+key1;
}
mt19937_64 rnd;
public:
RandGen(string s){
for(unsigned char i:s){
shift2(i);
shift1();
}
for(int i=1;i<=5;++i) shift1(),shift2(i);
rnd.seed(key1^key2);
}
RandGen(int x=0){
shift2(x);
shift1();
for(int i=1;i<=5;++i) shift1(),shift2(i);
rnd.seed(key1^key2);
}
void seed(string s){
(*this)=RandGen(s);
}
void seed(int x=0){
(*this)=RandGen(x);
}
ull operator()(){
shift1();
shift2(key1);
shift2(key2);
shift1();
return key1^key2^rnd();
}
};
namespace GenSpace{
template<typename T,typename TT>vector<T> alist(T start,T end,TT step=1){//生成有序数列:(起始,终止,步长)
vector<T> v;
for(T i=start;(step>0?i<=end:i>=end);i+=step){
v.push_back(i);
}
return v;
}
template<typename T,class F1,class F2>vector<T> alist(T start,T end,F1 nxt,F2 chk){//生成有序数列:(起始,终止,下一步,判断条件)
vector<T> v;
for(T i=start;chk(i,end);i=nxt(i)){
v.push_back(i);
}
return v;
}
string astr(char start,char end,char step=1){//生成有序字符串
string s;
for(int i=start;(step>0?i<=end:i>=end);i+=step){
s.push_back((char)i);
}
return s;
}
//---------------使用RandGen
RandGen _rand(0);
template<typename T>T rint(T l,T r,RandGen &rnd=_rand){//随机生成整数:(区间,随机引擎)。
assert(l<=r);
return rnd()%(r-l+1)+l;
}
template<typename T>T real(T l,T r,ull precision=1000,RandGen &rnd=_rand){//随机生成实数:(区间,精度,随机引擎)。
return 1.0*rint<ull>(0ull,precision,rnd)/precision*(r-l)+l;
}
string rstr(ull len,char l,char r,RandGen &rnd=_rand){//随机生成字符串
string s;
for(int i=0;i<len;++i) s+=rint<char>(l,r,rnd);
return s;
}
template<typename T>vector<T> rilist(ull len,T l,T r,RandGen &rnd=_rand){//随机生成整数数组:(长度,区间,随机引擎)
vector<T> tmp(len);
for(int i=0;i<len;++i) tmp[i]=rint<T>(l,r,rnd);
return tmp;
}
template<typename T>vector<T> rrlist(ull len,T l,T r,ull precision=1000,RandGen &rnd=_rand){//随机生成实数数组:(长度,区间,精度,随机引擎)
vector<T> tmp(len);
for(int i=0;i<len;++i) tmp[i]=real<T>(l,r,precision,rnd);
return tmp;
}
template<typename Pointer>Pointer rpick(Pointer begin,Pointer end,RandGen &rnd=_rand){//随机挑选:(起始,终止,随机引擎)
assert(begin<end);
return begin+rint<ull>(0,end-begin-1,rnd);
}
template<typename Pointer>void Shuffle(Pointer begin,Pointer end,ull times=0,RandGen &rnd=_rand){//随机打乱:(起始,终止,打乱程度,随机引擎)
assert(begin<=end);
if(times==0) times=end-begin;
while(times--){
ull x=rint<ull>(0,end-begin-1,rnd);
ull y=rint<ull>(0,end-begin-1,rnd);
swap(*(begin+x),*(begin+y));
}
}
}
template<ostream& out=cout,typename T>
T output(T x,char end='\n'){
out<<x<<end;
return x;
}
template<ostream& out=cout,typename T1,typename T2>
pair<T1,T2> output(pair<T1,T2> x,char gap=' ',char end='\n'){
output<out>(x.first,gap);
output<out>(x.second,end);
return x;
}
template<ostream& out=cout,typename T>
vector<T> output(vector<T> v,char gap=' ',char end='\n'){
for(ull i=0;i+1<(ull)v.size();++i) output<out>(v[i],gap);
if(!v.empty()) output<out>(v.back(),end);
return v;
}
template<ofstream& out,typename T>
T output(T x,char end='\n'){
out<<x<<end;
return x;
}
template<ofstream& out,typename T1,typename T2>
pair<T1,T2> output(pair<T1,T2> x,char gap=' ',char end='\n'){
output<out>(x.first,gap);
output<out>(x.second,end);
return x;
}
template<ofstream& out,typename T>
vector<T> output(vector<T> v,char gap=' ',char end='\n'){
for(ull i=0;i+1<(ull)v.size();++i) output<out>(v[i],gap);
if(!v.empty()) output<out>(v.back(),end);
return v;
}
template<typename T>
vector<T> operator + (vector<T> x,vector<T> y){
vector<T> t=x;
for(T i:y) t.push_back(i);
return t;
}
template<typename T>
vector<T>& operator += (vector<T> &x,vector<T> y){
for(T i:y) x.push_back(i);
return x;
}
ofstream fout;
void InitGen(int argc,char* argv[]){
if(argc<3) exitcode(-1,"参数过少,按照以下方式传参:<种子> <生成文件>");
GenSpace::_rand.seed(argv[1]);
fout.open(argv[2]);
if(!fout.is_open()) exitcode(-1,(string)"无法输出到文件:"+argv[2]);
addlog("The generator is ready!","生成器准备完成!");
}
void Start(){
system(("chcp "+behavior::chcp+" > nul").c_str()); //将控制台编码改为utf-8
}
#endif
版权说明:
这个头文件是蒟蒻自己敲出来的,仅使用 DeepSeek 检查代码中的 UB 行为,转载请说明来源,感谢各位大佬的支持。