常用链接
快速IO
#include<bits/stdc++.h>
#if defined(_WIN32)
#define gc _getchar_nolock
#define pc _putchar_nolock
#else
#define gc getchar_unlocked
#define pc putchar_unlocked
#endif
#define edl pc('\n')
using namespace std;
int rd(){
int x = 0, d = 1; int c = gc();
while (!isdigit(c)){if (c == '-') d = -1; c = gc();}
while (isdigit(c)) x *= 10, x += c - '0', c = gc();
return x * d;
}
void put(unsigned int x){
int n = 0; char c[32];
do{
c[n++] = x % 10 + '0';
x /= 10;
}while(x);
while(n--) pc(c[n]);
}
void wt(int x){
unsigned int ux = x;
if (x < 0) ux = -ux, pc('-');
put(ux);
}对拍/调试用
#include <bits/stdc++.h>
using namespace std;
int main() {
srand((unsigned)time(nullptr));
system("g++ -O2 -std=c++14 gen.cpp -o gen");
system("g++ -O2 -std=c++14 fixedhuman.cpp -o brute");
system("g++ -O2 -std=c++14 human.cpp -o std");
cout << "编译完成\n";
for (int i = 1;; i++) {
int seed = rand();
system(("gen.exe " + to_string(seed) + " > data.in").c_str());
auto std_start = chrono::steady_clock::now();
system("std.exe < data.in > std.out");
auto std_end = chrono::steady_clock::now();
double std_time = chrono::duration<double, milli>(std_end - std_start).count();
auto brute_start = chrono::steady_clock::now();
system("brute.exe < data.in > brute.out");
auto brute_end = chrono::steady_clock::now();
double brute_time = chrono::duration<double, milli>(brute_end - brute_start).count();
if (system("fc std.out brute.out")) {
cout << "WA seed = " << seed << endl;
cout << "std time: " << fixed << setprecision(3) << std_time << " ms\n";
cout << "brute time: " << fixed << setprecision(3) << brute_time << " ms\n";
return 0;
}
cout << "Test " << i << " OK | std: " << fixed << setprecision(3) << std_time
<< " ms, brute: " << brute_time << " ms" << endl;
}
return 0;
}