其他

随机数 Random #include <bits/stdc++.h>using namespace std; typedef long long LL; struct FastIO { FastIO() { ios::sync_with_stdio(false); cin.tie(nullptr); } }fastio; mt19937 rnd(chrono::system_clock::now().time_since_epoch().count()); mt19937_64 rnd_64(chrono::system_clock::now().time_since_epoch().count()); // [0,r) int rndi(int r) { return rnd()%r; } // [l,r] r-l+1<=INT_MAX int rndi(int l,int r) { return rnd()%(r-l+1)+l; } LL rndll(LL l,LL r) { return rnd_64()%(r-l+1)+l; } char rndc() { return rndi(-128,127); } char rndc(const string &s) { return s[rndi(s.length())]; } char rnd_lower() { return rndi(26)+'a'; } char rnd_upper() { return rndi(26)+'A'; } char rnd_digit() { return rndi(10)+'0'; } char rnd_alpha() { int r=rndi(52); return r<26?(r+'a'):(r-26+'A'); } char rnd_alphadigit() { int r=rndi(62); if(r<10) return
对拍程序 from os import system tc=0 while True: system("python data.py > data.in") system("std.exe < data.in > std.out") system("my.exe < data.in > my.out") # system("diff std.out my.out > diff.out"): if system("fc std.out my.out > diff.out"): print("WA") break else: tc += 1 print("AC #%d"%tc) print("-------------------- data.in --------------------") # system("cat data.in") system("type data.in") print("-------------------- std.out --------------------") system("type std.out") print("-------------------- my.out ---------------------") system("type my.out") Powershell #include <bits/stdc++.h>using namespace std; int main() { int tc=0; while(1) { system("./E_data > data.in"); system("cat data.in | ./E_std.exe > std.txt"); system("cat data.in | ./E.exe > my.txt"); if(system("diff std.txt my.txt > diff.txt")) { cout<<"WA"<<endl; break; } else
计时 Timing chrono class Timing { private: typedef chrono::time_point<std::chrono::high_resolution_clock> TP; TP current_time() { return chrono::high_resolution_clock::now(); } TP st,ed; public: void start() { st=current_time(); } void end() { ed=current_time(); } void print() { cout<<chrono::duration_cast<chrono::microseconds>(ed-st).count() <<"ms\n"; } }timing;