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