https://mp.weixin.qq.com/s/jbfprtGiupQPUu2ABAaybQ
快读(C++11):
Code
namespace io{char buf[1<<21],*p1=buf,*p2=buf;inline char gc(){return(p1==p2&&(p2=(p1=buf)+cin.rdbuf()->sgetn(buf,1<<21),p1==p2)?EOF:*p1++);}inline void pc(const char x){cout.rdbuf()->sputc(x);}template<typename T>inline void read(T&x){x=0;char f=0,c;while(!isdigit(c=gc()))f|=c=='-';while(isdigit(c))x=(x*10-'0'+c),c=gc();x=f?-x:x;}template<typename T=int>inline T read(){T s;read(s);return s;}inline void read(char*s){char c;while(isspace(c=gc()));while(!isspace(c)&&c!=EOF)*s++=c,c=gc();}template<typename T>inline void write(T x){static char S[150];x<0&&(pc('-'),(x=-x));int p=0;do{S[p++]=x%10^48;x/=10;}while(x);while(p--)cout.rdbuf()->sputc(S[p]);}inline void write(char*s){do{cout.rdbuf()->sputc(*s++);}while(*s);}inline void write(const char*s){do{cout.rdbuf()->sputc(*s++);}while(*s);}template<typename T>inline void writeln(const T x){write(x);pc(10);}template<typename T>inline void writesp(const T x){write(x);pc(' ');}template<typename T,typename...Args>inline void read(T&x,Args&...args){read(x),read(args...);}template<typename T,typename...Args>inline void write(T x,Args ...args){write(x),pc(' '),write(args...);}}using namespace io;
//without double
namespace io{char buf[1<<21],*p1=buf,*p2=buf;inline char gc(){return(p1==p2&&(p2=(p1=buf)+cin.rdbuf()->sgetn(buf,1<<21),p1==p2)?EOF:*p1++);}template<typename T>inline void read(T&x){x=0;char f=0,c;while(!isdigit(c=gc()))f|=c=='-';while(isdigit(c))x=(x*10-'0'+c),c=gc();x=f?-x:x;}template<typename T=int>inline T read(){T s;read(s);return s;}inline void read(char*s){char c;while(isspace(c=gc()));while(!isspace(c)&&c!=EOF)*s++=c,c=gc();}template<typename T,typename...Args>inline void read(T&x,Args&...args){read(x),read(args...);}}using namespace io;
//without output:
Code
struct pairhash{
public:
template<typename T,typename U>
size_t operator()(const pair<T,U>&x)const{
return hash<T>()(x.first)^hash<U>()(x.second);
}
};unordered_map<pair<int,int>,int,pairhash>mp;可用火车头:
Code
#define orz GCC
#pragma orz optimize("Ofast,-falign-functions,-falign-jumps,-falign-labels,-falign-loops,-fcaller-saves,-fcrossjumping,-fcse-follow-jumps,-fdelete-null-pointer-checks,-fdevirtualize,-fexpensive-optimizations,-ffast-math,-fgcse,-fgcse-lm,-fhoist-adjacent-loads,-findirect-inlining,-finline,-fipa-sra,-fno-stack-protector,-foptimize-sibling-calls,-fpartial-inlining,-fpeephole2,-freorder-blocks,-freorder-functions,-frerun-cse-after-loop,-fsched-interblock,-fsched-spec,-fschedule-insns,-fschedule-insns2,-fstrict-aliasing,-fthread-jumps,-ftree-pre,-ftree-switch-conversion,-ftree-tail-merge,-ftree-vrp,-funroll-loops")
#pragma orz target("abm,avx,mmx,popcnt,sse,sse2,sse3,sse4,ssse3,tune=native")