zoukankan      html  css  js  c++  java
  • IO 优化

    转自 BlackJack_

    #define fastcall __attribute__((optimize("-O3")))
    #define IL __inline__ __attribute__((always_inline))
     
    #ifdef ONLINE_JUDGE
    char *TT,*mo,but[(1<<15)+2];
    #define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin)),TT==mo)?0:*TT++)
    #endif
    fastcall IL int read()
    {
    	int x=0,ch=0;
    	while(ch<'0'||ch>'9')ch=getchar();
    	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    	return x;
    }
    fastcall void print(int x)
    {if(x<0)putchar('-'),x=-x;if(x>=10)print(x/10);putchar(x%10+'0');}
    
    
    #include <cstdio>
     
    using namespace std;
     
    namespace io {
    	const int SIZE = (1 << 21) + 1;
    	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
    	// getchar
    	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
    	// print the remaining part
    	inline void flush () {
    		fwrite (obuf, 1, oS - obuf, stdout);
    		oS = obuf;
    	}
    	// putchar
    	inline void putc (char x) {
    		*oS ++ = x;
    		if (oS == oT) flush ();
    	}
    	// input a signed integer
    	template <class I>
    	inline void gi (I &x) {
    		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
    		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
    	}
    	// print a signed integer
    	template <class I>
    	inline void print (I &x) {
    		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
    		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
    		while (qr) putc (qu[qr --]);
    	}
    }
    using io :: gi;
    using io :: putc;
    using io :: print;
     
    int v;
     
    int main () {
    	gi (v);
    	print (v);
    	putc ('
    ');
    	io :: flush ();
    }
    
    
  • 相关阅读:
    CQUOJ 10819 MUH and House of Cards
    CQUOJ 9920 Ladder
    CQUOJ 9906 Little Girl and Maximum XOR
    CQUOJ 10672 Kolya and Tandem Repeat
    CQUOJ 9711 Primes on Interval
    指针试水
    Another test
    Test
    二分图匹配的重要概念以及匈牙利算法
    二分图最大匹配
  • 原文地址:https://www.cnblogs.com/SGCollin/p/10271116.html
Copyright © 2011-2022 走看看