正文
增加 213 行删除 14 行
123456789101112131415161718192021222324252627282930313233343536373839407 行未改动4849505152535455### 前言这些都是按照自己的习惯写的,代码风格因人而异。### 板子```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 any template<typename T>#define fs(x) fixed<<setprecision(x)#define ll long long#define ull unsigned long long#define debug(x) cout<<"Line "<<__LINE__<<","<<(x)<<"."<<endlany inline void chkmax(T &x,T y){if(x<y){x=y;}}any inline void chkmin(T &x,T 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;bool memorybegin;void code(){//do something...}bool memoryend;int main(){#define DEBUG mofan101028ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); code();#ifdef DEBUGcout<<"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;#endifreturn 0;}```板子随时调整。### 规范- 要尽量压行,每个代码块之间空一个空格。:::info[例子]7 行未改动cin>>a;cin>>b;cout<<a+b<<endl;```(暂且不管板子中const那一行):::[](https://www.luogu.me/article/g4uriq8f)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282297 行未改动237238239240241242243244245246247248249250251252253254:::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 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;}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;}```板子随时调整。### 拍子:::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[例子]7 行未改动cin>>a;cin>>b;cout<<a+b<<endl;```:::- 括号里内容比较少就不换行。:::info[例子]如板子中的 $\text{chkmax}$ 和 $\text{chkmin}$ 。:::### 一些标识符`pow2[i]`表示 ${2}^{i}$ 的值。`lg2[i]`表示 $\log_2i$ 的值。[](https://www.luogu.me/article/g4uriq8f)