读入输出优化
1 #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++) 2 char buf[1 << 21], *p1 = buf, *p2 = buf; 3 template < class T > 4 inline void read(T & x) 5 { 6 x = 0; char c = getchar(); bool f = 0; 7 for(; !isdigit(c); c = getchar()) f ^= c == '-'; 8 for(; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); 9 x = f ? -x : x; 10 return; 11 } 12 template < class T > 13 inline void write(T x) 14 { 15 if(x < 0) putchar('-'), x = -x; 16 T y = 1; int len = 1; 17 for(; y <= x / 10; y *= 10) ++len; 18 for(; len; --len, x %= y, y /= 10) putchar(x / y + 48); 19 return; 20 }
氧:
1 #pragma GCC optimize(2) 2 #pragma GCC optimize(3) 3 #pragma GCC optimize("Ofast") 4 #pragma GCC optimize("inline") 5 #pragma GCC optimize("-fgcse") 6 #pragma GCC optimize("-fgcse-lm") 7 #pragma GCC optimize("-fipa-sra") 8 #pragma GCC optimize("-ftree-pre") 9 #pragma GCC optimize("-ftree-vrp") 10 #pragma GCC optimize("-fpeephole2") 11 #pragma GCC optimize("-ffast-math") 12 #pragma GCC optimize("-fsched-spec") 13 #pragma GCC optimize("unroll-loops") 14 #pragma GCC optimize("-falign-jumps") 15 #pragma GCC optimize("-falign-loops") 16 #pragma GCC optimize("-falign-labels") 17 #pragma GCC optimize("-fdevirtualize") 18 #pragma GCC optimize("-fcaller-saves") 19 #pragma GCC optimize("-fcrossjumping") 20 #pragma GCC optimize("-fthread-jumps") 21 #pragma GCC optimize("-funroll-loops") 22 #pragma GCC optimize("-fwhole-program") 23 #pragma GCC optimize("-freorder-blocks") 24 #pragma GCC optimize("-fschedule-insns") 25 #pragma GCC optimize("inline-functions") 26 #pragma GCC optimize("-ftree-tail-merge") 27 #pragma GCC optimize("-fschedule-insns2") 28 #pragma GCC optimize("-fstrict-aliasing") 29 #pragma GCC optimize("-fstrict-overflow") 30 #pragma GCC optimize("-falign-functions") 31 #pragma GCC optimize("-fcse-skip-blocks") 32 #pragma GCC optimize("-fcse-follow-jumps") 33 #pragma GCC optimize("-fsched-interblock") 34 #pragma GCC optimize("-fpartial-inlining") 35 #pragma GCC optimize("no-stack-protector") 36 #pragma GCC optimize("-freorder-functions") 37 #pragma GCC optimize("-findirect-inlining") 38 #pragma GCC optimize("-frerun-cse-after-loop") 39 #pragma GCC optimize("inline-small-functions") 40 #pragma GCC optimize("-finline-small-functions") 41 #pragma GCC optimize("-ftree-switch-conversion") 42 #pragma GCC optimize("-foptimize-sibling-calls") 43 #pragma GCC optimize("-fexpensive-optimizations") 44 #pragma GCC optimize("-funsafe-loop-optimizations") 45 #pragma GCC optimize("inline-functions-called-once") 46 #pragma GCC optimize("-fdelete-null-pointer-checks")