快读

· · 个人记录

namespace Super_Invincibl_Universe_Thunderbolt_Fast_Read_and_Write{
    #define IOSIZE 100000
    char ibuf[IOSIZE],obuf[IOSIZE],*p1=ibuf,*p2=ibuf,*p3=obuf;
    #define Super_Invincibl_Universe_Thunderbolt_Fast_Read() ((p1==p2)and(p2=(p1=ibuf)+fread(ibuf,1,IOSIZE,stdin),p1==p2)?(EOF):(*p1++))
    #define Super_Invincibl_Universe_Thunderbolt_Fast_Write(x) ((p3==obuf+IOSIZE)&&(fwrite(obuf,p3-obuf,1,stdout),p3=obuf),*p3++=x)
    #define isdigit(ch) (ch>47&&ch<58)
    #define isspace(ch) (ch<33)
    template<typename T>inline T read(){T s=0;int w=1;char ch;while(ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read(),!isdigit(ch)&&(ch!=EOF))if(ch=='-')w=-1;if(ch==EOF)return 0;while(isdigit(ch))s=s*10+ch-48,ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read();return s*w;}
    template<typename T>inline bool read(T&s){s=0;int w=1;char ch;while(ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read(),!isdigit(ch)&&(ch!=EOF))if(ch=='-')w=-1;if(ch==EOF)return 0;while(isdigit(ch))s=s*10+ch-48,ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read();return s*=w,1;}
    template<typename T>inline void print(T x){if(x<0)Super_Invincibl_Universe_Thunderbolt_Fast_Write('-'),x=-x;if(x>9)print(x/10);Super_Invincibl_Universe_Thunderbolt_Fast_Write(x%10+48);}
    inline bool read(char&s){while(s=Super_Invincibl_Universe_Thunderbolt_Fast_Read(),isspace(s));return 1;}
    inline bool read(char*s){char ch;while(ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read(),isspace(ch));if(ch==EOF)return 0;while(!isspace(ch))*s++=ch,ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read();*s='\000';return 1;}
    inline void print(char x){Super_Invincibl_Universe_Thunderbolt_Fast_Write(x);}
    inline void print(char*x){while(*x)Super_Invincibl_Universe_Thunderbolt_Fast_Write(*x++);}
    inline void print(const char*x){for(int i=0;x[i];i++)Super_Invincibl_Universe_Thunderbolt_Fast_Write(x[i]);}
    inline bool read(std::string&s){s="";char ch;while(ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read(),isspace(ch));if(ch==EOF)return 0;while(!isspace(ch))s+=ch,ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read();return 1;}
    inline void print(std::string x){for(int i=0,n=x.size();i<n;i++)Super_Invincibl_Universe_Thunderbolt_Fast_Write(x[i]);}
    inline bool read(bool&b){char ch;while(ch=Super_Invincibl_Universe_Thunderbolt_Fast_Read(),isspace(ch));b=ch^48;return 1;}
    inline void print(bool b){Super_Invincibl_Universe_Thunderbolt_Fast_Write(b+48);}
    template<typename T,typename...T1>inline int read(T&a,T1&...other){return read(a)+read(other...);}
    template<typename T,typename...T1>inline void print(T a,T1...other){print(a),print(other...);}
    struct Fast_IO{~Fast_IO(){fwrite(obuf,p3-obuf,1,stdout);}}io;
    template<typename T>Fast_IO&operator>>(Fast_IO&io,T&b){return read(b),io;}
    template<typename T>Fast_IO&operator<<(Fast_IO&io,T b){return print(b),io;}
    #define cout io
    #define cin io
    #define endl '\n'
}using namespace Super_Invincibl_Universe_Thunderbolt_Fast_Read_and_Write;