正文
增加 197 行删除 4 行
12345674 行未改动1213141516171819202122232425265 行未改动323334353637383940414214 行未改动5758596061### 前言这些都是按照自己的习惯写的,代码风格因人而异。### 板子```cpp#include <bits/stdc++.h>4 行未改动#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); perf();return 0;5 行未改动bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}```板子随时调整。### 规范- 要尽量压行,每个代码块之间空一个空格。:::info[例子]14 行未改动:::info[例子]如板子中的 $\text{chkmax}$ 和 $\text{chkmin}$ 。:::[](https://www.luogu.me/article/g4uriq8f)12345674 行未改动12131415161718192021222324252627285 行未改动34353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822914 行未改动244245246247248249250251252253254:::info[前言]这些都是按照自己的习惯写的,代码风格因人而异。:::### 板子```cpp#include <bits/stdc++.h>4 行未改动#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define fi first#define se second#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps; const ll mod=998244353;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); perf();return 0;5 行未改动bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}```板子随时调整。### 拍子:::info[内容]板子(可能与最新板子不同):```cpp#include <bits/stdc++.h>using namespace std;#define upp(x,y,z) for(x=(y);x<=(z);++x)#define low(x,y,z) for(x=(y);x>=(z);--x)#define tt template<typename t0>#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); perf();return 0;}bool memorybegin;void code(){//do something...}bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}```正确程序(求 $a \oplus b$ ):```cpp#include <bits/stdc++.h>using namespace std;#define upp(x,y,z) for(x=(y);x<=(z);++x)#define low(x,y,z) for(x=(y);x>=(z);--x)#define tt template<typename t0>#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); //perf();return 0;}bool memorybegin;void code(){freopen("random.in","r",stdin);freopen("correct.out","w",stdout);ull a,b; cin>>a>>b; cout<<(a^b)<<endl;}bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}```正确性待验证程序:```cpp#include <bits/stdc++.h>using namespace std;#define upp(x,y,z) for(x=(y);x<=(z);++x)#define low(x,y,z) for(x=(y);x>=(z);--x)#define tt template<typename t0>#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); //perf();return 0;}bool memorybegin;void code(){freopen("random.in","r",stdin);freopen("solution.out","w",stdout);ull a,b; cin>>a>>b; cout<<((a&(~b))|((~a)&b))<<endl;}bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}```随机数据生成器:~~~ cpp#include <bits/stdc++.h>using namespace std;#define upp(x,y,z) for(x=(y);x<=(z);++x)#define low(x,y,z) for(x=(y);x>=(z);--x)#define tt template<typename t0>#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); //perf();return 0;}bool memorybegin;void code(){freopen("random.in","w",stdout);srand(time(0)); ull a,b,c,d; a=rand(); b=rand(); c=rand(); d=rand();cout<<a*b<<" "<<c*d<<endl;}bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}~~~对拍核心程序(Windows 11 下可用):```cpp#include <bits/stdc++.h>using namespace std;#define upp(x,y,z) for(x=(y);x<=(z);++x)#define low(x,y,z) for(x=(y);x>=(z);--x)#define tt template<typename t0>#define fs(x) fixed<<setprecision(x)#define pb push_back#define ub upper_bound#define lb lower_bound#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endltt inline void chkmax(t0 &x,t0 y){if(x<y){x=y;}}tt inline void chkmin(t0 &x,t0 y){if(x>y){x=y;}}const int eps=0xf; const int inf=0x7fffffff; const ll infll=0x7fffffffffffffff; const ull infull=0xffffffffffffffff;const int N=1e6+eps;void code(); void perf();int main(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code(); //perf();return 0;}bool memorybegin;void code(){int T=10; int i; double t1,t2;freopen("bat.out","w",stdout);upp(i,1,T){system("random.exe");t1=(double)clock()/CLOCKS_PER_SEC; system("solution.exe");t2=(double)clock()/CLOCKS_PER_SEC; system("correct.exe");if(system("fc solution.out correct.out")){cout<<"WA in #"<<i<<"."<<endl; return;}cout<<"AC in #"<<i<<", time used:"<<fs(3)<<t2-t1<<"s."<<endl;}}bool memoryend;void perf(){cout<<"CPU time used:"<<fs(3)<<(double)clock()/CLOCKS_PER_SEC<<"s."<<endl;cout<<"Memory used:"<<fs(3)<<abs((&memoryend-&memorybegin)*1.0/1024.0/1024.0)<<"MB."<<endl;}```:::### 规范- 要尽量压行,每个代码块之间空一个空格。:::info[例子]14 行未改动:::info[例子]如板子中的 $\text{chkmax}$ 和 $\text{chkmin}$ 。:::### 一些标识符`pow2[i]`表示 ${2}^{i}$ 的值。`lg2[i]`表示 $\log_2i$ 的值。[](https://www.luogu.me/article/g4uriq8f)