版本比较
多方对拍
正文
增加 23 行删除 4 行
12345610 行未改动17181920212223242526272829303132333435 行未改动7071727374757677787980818283848586878889909192939495969798991001011023 行未改动10610710810911011111211311411511611711840 行未改动racket.cpp```cpp#include <string>#include <cstdio>#include <vector>10 行未改动{if(filesystem::exists("D:\\working\\" + x + ".hash.bak")){sstm("certutil -hashfile D:\\working\\" + x + ".cpp SHA256 > D:\\working\\" + x + ".hash");if(!sstm("D:\\working\\diff.exe D:\\working\\" + x + ".hash D:\\working\\" + x + ".hash.bak")){// printf("Hash is the same. do not compile.\n");return true;}if(sstm("g++ -std=c++17 -Ofast -march=native D:\\working\\" + x + ".cpp -o D:\\working\\" + x + ".exe")){// printf("Failed when compiling %s.cpp.\n", x.c_str());return false;}filesystem::rename("D:\\working\\" + x + ".hash", "D:\\working\\" + x + ".hash.bak");}else{35 行未改动{printf("Failed when compiling maker.cpp.\n");return 4;}for(const auto &x : names){printf("[log] build %s.cpp\n", x.c_str());if(!do_compile(x)){printf("Failed when compiling %s.cpp.\n", x.c_str());return 8;}}do{printf("[log] execute maker.exe\n");int stat = 0;if(stat = sstm("D:\\working\\maker.exe > D:\\working\\data.in")){printf("maker returned %d\n", stat);return 16;}for(const auto &x : names){printf("[log] execute %s.exe\n", x.c_str());if(stat = sstm("D:\\working\\" + x + ".exe < D:\\working\\data.in > D:\\working\\" + x + ".out")){printf("%s.exe returned %d\n", x.c_str(), stat);return 32;}}for(int i=0;i+1<names.size();i++){3 行未改动printf("%s.out != %s.out.\n", names[i].c_str(), names[i+1].c_str());goto ed;}}} while(true);ed:printf("Wrong Answer.\n");return 0;}```diff.cpp(fc 太慢)40 行未改动1234567810 行未改动19202122232425262728293031323334353637383935 行未改动757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181193 行未改动12312412512612712812913013113213313413513613740 行未改动racket.cpp之前的 hash 存储管理有些问题,会炸掉,现在好了。```cpp#include <string>#include <cstdio>#include <vector>10 行未改动{if(filesystem::exists("D:\\working\\" + x + ".hash.bak")){sstm("certutil -hashfile D:\\working\\" + x + ".cpp SHA256 > D:\\working\\" + x + ".hash");if(!sstm("D:\\working\\diff.exe D:\\working\\" + x + ".hash D:\\working\\" + x + ".hash.bak")){filesystem::remove("D:\\working\\" + x + ".hash");// printf("Hash is the same. do not compile.\n");return true;}if(sstm("g++ -std=c++17 -Ofast -march=native D:\\working\\" + x + ".cpp -o D:\\working\\" + x + ".exe")){filesystem::remove("D:\\working\\" + x + ".hash");// printf("Failed when compiling %s.cpp.\n", x.c_str());return false;}filesystem::remove("D:\\working\\" + x + ".hash.bak");filesystem::rename("D:\\working\\" + x + ".hash", "D:\\working\\" + x + ".hash.bak");}else{35 行未改动{printf("Failed when compiling maker.cpp.\n");return 4;}printf("[log] build validator.cpp\n");if(!do_compile("validator")){printf("Failed when compiling validator.cpp.\n");return 8;}for(const auto &x : names){printf("[log] build %s.cpp\n", x.c_str());if(!do_compile(x)){printf("Failed when compiling %s.cpp.\n", x.c_str());return 16;}}do{printf("[log] execute maker.exe\n");int stat = 0;if(stat = sstm("D:\\working\\maker.exe > D:\\working\\data.in")){printf("maker returned %d\n", stat);return 32;}printf("[log] execute validator.exe\n");if(sstm("D:\\working\\validator.exe < D:\\working\\data.in")){printf("Data invalid.\n");continue;}for(const auto &x : names){printf("[log] execute %s.exe\n", x.c_str());if(stat = sstm("D:\\working\\" + x + ".exe < D:\\working\\data.in > D:\\working\\" + x + ".out")){printf("%s.exe returned %d\n", x.c_str(), stat);return 64;}}for(int i=0;i+1<names.size();i++){3 行未改动printf("%s.out != %s.out.\n", names[i].c_str(), names[i+1].c_str());goto ed;}}printf("Accepted.\n");} while(true);ed:printf("Wrong Answer.\n");return 0;}```diff.cpp(fc 太慢)40 行未改动