火车头-plus
xpg007
·
·
个人记录
namespace FastIO{
constexpr int IOSIZE=1<<20;
char ibuf[IOSIZE],obuf[IOSIZE];
char*p1=ibuf,*p2=ibuf,*p3=obuf;
inline char _gc(){if(p1==p2){p2=(p1=ibuf)+fread(ibuf,1,IOSIZE,stdin);if(p1==p2)return EOF;}return*p1++;}
inline void _pc(char c){if(p3==obuf+IOSIZE){fwrite(obuf,1,p3-obuf,stdout);p3=obuf;}*p3++=c;}
inline bool _isdigit(char c){return c>='0'&&c<='9';}
inline bool _isspace(char c){return c<=' ';}
template<typename T,bool IsSigned=std::is_signed<T>::value>struct IntReader{static void read(T&x){char c;while(!_isdigit(c=_gc()));x=c-'0';while(_isdigit(c=_gc()))x=x*10+(c-'0');}};
template<typename T>struct IntReader<T,true>{static void read(T&x){char c;while(!_isdigit(c=_gc())&&c!='-');bool neg=(c=='-');if(neg)c=_gc();x=c-'0';while(_isdigit(c=_gc()))x=x*10+(c-'0');if(neg)x=-x;}};
template<typename T,bool IsSigned=std::is_signed<T>::value>struct IntWriter{static void write(T x){if(x==0){_pc('0');return;}char buf[20];int n=0;do{buf[n++]=x%10+'0';x/=10;}while(x);while(n--)_pc(buf[n]);}};
template<typename T>struct IntWriter<T,true>{static void write(T x){if(x==0){_pc('0');return;}if(x<0){_pc('-');x=-x;}char buf[20];int n=0;do{buf[n++]=x%10+'0';x/=10;}while(x);while(n--)_pc(buf[n]);}};
inline void read(int&x){IntReader<int>::read(x);}
inline void read(long long&x){IntReader<long long>::read(x);}
inline void read(unsigned int&x){IntReader<unsigned int>::read(x);}
inline void read(unsigned long long&x){IntReader<unsigned long long>::read(x);}
inline void read(short&x){IntReader<short>::read(x);}
inline void read(long&x){IntReader<long>::read(x);}
inline void read(char&x){while(_isspace(x=_gc()));}
inline void read(bool&b){char c;while(_isspace(c=_gc()));b=(c!='0'&&c!='f');}
inline void read(std::string&s){char c;while(_isspace(c=_gc()));s.clear();do{s+=c;}while(!_isspace(c=_gc()));}
template<typename T>typename std::enable_if<std::is_floating_point<T>::value,void>::type read(T&x){char c;while(!_isdigit(c=_gc())&&c!='-'&&c!='.');bool neg=(c=='-');if(c=='-'||c=='.')c=_gc();x=0;T base=1;while(_isdigit(c)){x=x*10+(c-'0');c=_gc();}if(c=='.'){c=_gc();while(_isdigit(c)){base*=0.1;x+=(c-'0')*base;c=_gc();}}if(neg)x=-x;}
inline void write(int x){IntWriter<int>::write(x);}
inline void write(long long x){IntWriter<long long>::write(x);}
inline void write(unsigned int x){IntWriter<unsigned int>::write(x);}
inline void write(unsigned long long x){IntWriter<unsigned long long>::write(x);}
inline void write(short x){IntWriter<short>::write(x);}
inline void write(long x){IntWriter<long>::write(x);}
inline void write(char x){_pc(x);}
inline void write(const char*x){while(*x)_pc(*x++);}
inline void write(const std::string&s){for(char c:s)_pc(c);}
inline void write(bool b){_pc(b?'1':'0');}
template<typename T,typename...Args>inline void read(T&x,Args&...args){read(x);read(args...);}
template<typename T,typename...Args>inline void write(const T&x,const Args&...args){write(x);write(args...);}
struct FastIO_{~FastIO_(){if(p3>obuf)fwrite(obuf,1,p3-obuf,stdout);}template<typename T>FastIO_& operator>>(T& x){read(x);return *this;}template<typename T>FastIO_& operator<<(const T& x){write(x);return *this;}}fio;
}using namespace FastIO;
#define cin FastIO::fio
#define cout FastIO::fio
#define endl '\n'