版本比较
快速读写
正文
增加 33 行删除 33 行
122345678910101112131415151617171819202122232424252626272829303132333334353637383839404142424344444546474849505051525354555656575859606161626364656667676869707172737475767677787980818182838485868787888990919293949596969798991009 行未改动1101111121131141141151161171182 行未改动1211221231241251251261271281291301301311321331341351361371371381391401411421421431441451461471481481491501501511521531541551551561571581591601611621621631641651661671671681691701711721731731741751751761771781791801811811821831831841851861871881891891901911921932 行未改动```c++class FastIO class FastIO{private: static const int BUFFER_SIZE=1<<16; char inBuffer[BUFFER_SIZE]; int inPos,inLength; char outBuffer[BUFFER_SIZE]; int outPos; void readBuffer() void readBuffer() { inPos=0; inLength=cin.read(inBuffer,BUFFER_SIZE).gcount(); } char getChar() char getChar() { if(inPos>=inLength) if(inPos>=inLength) { readBuffer(); } if(inLength==0) return EOF; return inBuffer[inPos++]; } void putChar(char c) void putChar(char c) { if(outPos>=BUFFER_SIZE) if(outPos>=BUFFER_SIZE) { flush(); } outBuffer[outPos++]=c; }public: FastIO():inPos(0),inLength(0),outPos(0) FastIO():inPos(0),inLength(0),outPos(0) { ios::sync_with_stdio(false); cin.tie(nullptr); } ~FastIO() ~FastIO() { flush(); } void flush() void flush() { if(outPos>0) if(outPos>0) { cout.write(outBuffer,outPos); outPos=0; } } void skipWhitespace() void skipWhitespace() { char c; while((c=getChar())!=EOF&&isspace(c)); if(c!=EOF) inPos--; } FastIO& operator>>(int& x) FastIO& operator>>(int& x) { skipWhitespace(); char c=getChar(); bool negative=false; if(c=='-') if(c=='-') { negative=true; c=getChar(); } x=0; while(c>='0'&&c<='9') while(c>='0'&&c<='9') { x=x*10+(c-'0'); c=getChar(); } if(negative) x=-x; if(c!=EOF) inPos--; return *this; } FastIO& operator>>(long long& x) FastIO& operator>>(long long& x) { skipWhitespace(); char c=getChar(); bool negative=false; if(c=='-') if(c=='-') { negative=true; c=getChar(); } x=0; while(c>='0'&&c<='9') while(c>='0'&&c<='9') { x=x*10+(c-'0'); c=getChar(); } if(negative) x=-x; if(c!=EOF) inPos--; return *this; } FastIO& operator>>(string& s) FastIO& operator>>(string& s) { skipWhitespace(); s.clear(); char c=getChar();9 行未改动 { skipWhitespace(); char c=getChar(); int i=0; while(c!=EOF&&!isspace(c)) while(c!=EOF&&!isspace(c)) { s[i++]=c; c=getChar(); }2 行未改动 return *this; } FastIO& operator<<(int x) { if(x==0) if(x==0) { putChar('0'); return *this; } if(x<0) if(x<0) { putChar('-'); x=-x; } char buffer[20]; int len=0; while(x>0) while(x>0) { buffer[len++]='0'+(x%10); x/=10; } for(int i=len-1;i>=0;i--) for(int i=len-1;i>=0;i--) { putChar(buffer[i]); } return *this; } FastIO& operator<<(long long x) FastIO& operator<<(long long x) { if(x==0) if(x==0) { putChar('0'); return *this; } if(x<0) if(x<0) { putChar('-'); x=-x; } char buffer[25]; int len=0; while(x>0) while(x>0) { buffer[len++]='0'+(x%10); x/=10; } for(int i=len-1;i>=0;i--) for(int i=len-1;i>=0;i--) { putChar(buffer[i]); } return *this; } FastIO& operator<<(const string& s) FastIO& operator<<(const string& s) { for(char c:s) for(char c:s) { putChar(c); } return *this; } FastIO& operator<<(const char* s) FastIO& operator<<(const char* s) { while(*s) while(*s) { putChar(*s++); } return *this; } FastIO& operator<<(char c) FastIO& operator<<(char c) { putChar(c); return *this; }2 行未改动