正文
增加 62 行删除 28 行
10 行未改动1112131415161718742 行未改动全部展开7617627637647657667677687697707717727737747757767777787797807817827837 行未改动79179279379479579679779879980080180280380480580680780880981081181281381481581681781881998 行未改动9189199209219229239249259269279289299309319329339349359369379389399409419429439442 行未改动947948949950951952953954955956957958959960961962963163 行未改动全部展开112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115145 行未改动11971198119912001201120212031204194 行未改动全部展开10 行未改动想了又想,改了无数个新式,最终确定以头文件的形式表现出来。你现在看见的,只不过是一个蒟蒻的脑洞大开,如有不足,可以指明更正;如果你不喜欢,就当看个乐子。# 食用说明这是头文件的介绍,当然您也可以在头文件中看到:742 行未改动全部展开#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;7 行未改动#define _RED 12#define _YELLOW 14#define _PURPLE 13void 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){98 行未改动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));}2 行未改动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(){163 行未改动全部展开for(T i:y) x.push_back(i);return x;}ofstream ouf;void InitGen(int argc,char* argv[]){if(argc<3) exitcode(-1,"参数过少,按照以下方式传参:<种子> <生成文件>");RandFunc::_rand.seed(argv[1]);ouf.open(argv[2]);if(!ouf.is_open()) exitcode(-1,(string)"无法输出到文件:"+argv[2]);addlog("The generator is ready!","生成器准备完成!");}void Start(){system(("chcp "+behavior::chcp+" > nul").c_str()); //将控制台编码改为utf-8}//输出相关struct OutputStyle{string start;45 行未改动}template<typename T>OutputPointer<multiset<T>> pack(multiset<T> v,OutputStyle s={"{",", ","}"}){return OutputPointer<multiset<T>>{v,s};}template<typename T1,typename T2>OutputMapPointer<map<T1,T2>> pack(map<T1,T2> v,OutPutMapStyle s={"{",{"[",", ","]"},": ",{"(",", ",")"},", ","}"}){return OutputMapPointer<map<T1,T2>>{v,s};}template<typename T1,typename T2>OutputMapPointer<multimap<T1,T2>> pack(multimap<T1,T2> v,OutPutMapStyle s={"{",{"[",", ","]"},": ",{"(",", ",")"},", ","}"}){194 行未改动全部展开10 行未改动11121314151617181920742 行未改动全部展开7637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947 行未改动80280380480580680780880981081181281381481581681781881982082182282382482582682782882983098 行未改动9299309319329339349359369379389399409419429439449459469479489499509519529539542 行未改动957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011163 行未改动全部展开1175117611771178117911801181118245 行未改动12281229123012311232123312341235123612371238194 行未改动全部展开10 行未改动想了又想,改了无数个新式,最终确定以头文件的形式表现出来。你现在看见的,只不过是一个蒟蒻的脑洞大开,如有不足,可以指明更正;如果你不喜欢,就当看个乐子。【26/11/20】正在尝试进行 linux 适配,目前可在 linux 环境下进行编译,但功能不全。# 食用说明这是头文件的介绍,当然您也可以在头文件中看到:742 行未改动全部展开#define DUIPAI#ifdef DUIPAI#include<bits/stdc++.h>using namespace std;typedef unsigned long long ull;typedef long long ll;#ifdef _WIN32/*--------------------------Windowes--------------------------------*/#include<windows.h>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 Start(){system(("chcp "+behavior::chcp+" > nul").c_str()); //将控制台编码改为utf-8}void addlog(string s,string t){ //写入日志/输出进程if(behavior::process&&t!="") std::cout<<t<<endl;if(!behavior::log||s=="") return;SYSTEMTIME T;7 行未改动#define _RED 12#define _YELLOW 14#define _PURPLE 13void 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){98 行未改动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));}2 行未改动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,"对拍出现错误,程序退出。");}#endif/*--------------------------\Windowes--------------------------------*/#ifdef __linux__/*--------------------------linux--------------------------------*/#include<time.h>namespace behavior{ //行为bool log=0; //是否输出日志bool process=0; //是否输出进程string compile="-std=c++14 -O2"; //编译命令ofstream logout("tls.log",ios::app);}void addlog(string s){if(!behavior::log) return;time_t timer=time(NULL);struct tm *T=localtime(&timer);behavior::logout<<T->tm_year+1900<<'/'<<T->tm_mon+1<<'/'<<T->tm_mday<<' ';behavior::logout<<T->tm_hour<<':'<<T->tm_min<<':'<<T->tm_sec<<' ';behavior::logout<<s<<'\n';}void addpro(string s){if(!behavior::process) return;cout<<s<<'\n';}void exitcode(int exitnum,string exitinfo){if(exitinfo!=""){if(exitnum==-1) cout<<"\033[31m错误\033[0m ";if(exitnum==-2) cout<<"\033[31m警告\033[0m ";cout<<exitinfo<<'\n';}exit(exitnum);}#endif/*--------------------------\linux--------------------------------*/class RandGen{//随机数生成器ull key1=0x1234567890abcdefull;ull key2=0xabcdef1234567890ull;void shift1(){163 行未改动全部展开for(T i:y) x.push_back(i);return x;}//输出相关struct OutputStyle{string start;45 行未改动}template<typename T>OutputPointer<multiset<T>> pack(multiset<T> v,OutputStyle s={"{",", ","}"}){return OutputPointer<multiset<T>>{v,s};}template<typename T1,typename T2>OutputMapPointer<map<T1,T2>> pack(map<T1,T2> v,OutputStyle s){return OutputMapPointer<map<T1,T2>>{v,map_s};}template<typename T1,typename T2>OutputMapPointer<map<T1,T2>> pack(map<T1,T2> v,OutPutMapStyle s={"{",{"[",", ","]"},": ",{"(",", ",")"},", ","}"}){return OutputMapPointer<map<T1,T2>>{v,s};}template<typename T1,typename T2>OutputMapPointer<multimap<T1,T2>> pack(multimap<T1,T2> v,OutPutMapStyle s={"{",{"[",", ","]"},": ",{"(",", ",")"},", ","}"}){194 行未改动全部展开