正文
增加 3 行删除 29 行
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545 行未改动6061626364656667683 行未改动7273747576777879803 行未改动848586878889909192936 行未改动100101102103104105106107108109110111112113114115116117118119120121122123124125126127128```cppnamespace FastIO {const int BUFFER_SIZE = 1 << 20; // 1MB 缓冲区// 输入缓冲区char in_buf[BUFFER_SIZE];char *in_ptr = in_buf;char *in_end = in_buf;// 输出缓冲区char out_buf[BUFFER_SIZE];char *out_ptr = out_buf;// 从 stdin 读取数据到输入缓冲区inline void load() {in_end = in_buf + fread(in_buf, 1, BUFFER_SIZE, stdin);in_ptr = in_buf;}// 获取一个字符(带缓冲)inline char getchar() {if (in_ptr == in_end) {load();if (in_ptr == in_end) return EOF;}return *in_ptr++;}// 输出一个字符(带缓冲)inline void putchar(char c) {if (out_ptr == out_buf + BUFFER_SIZE) {fwrite(out_buf, 1, BUFFER_SIZE, stdout);out_ptr = out_buf;}*out_ptr++ = c;}// 刷新输出缓冲区inline void flush() {fwrite(out_buf, 1, out_ptr - out_buf, stdout);out_ptr = out_buf;}// 读取整数(支持负数)template <typename T>inline bool read(T &x) {x = 0;char c = getchar();bool negative = false;// 跳过空白字符while (c != EOF && isspace(c)) c = getchar();if (c == EOF) return false;if (c == '-') {negative = true;5 行未改动}if (negative) x = -x;return true;}// 读取字符串(以空白字符分隔)(string)inline bool read(std::string &s) {s.clear();char c = getchar();while (c != EOF && isspace(c)) c = getchar();3 行未改动c = getchar();}return true;}// 读取字符串(以空白字符分隔)(char)inline bool read(char *s) {char c = getchar();while (c != EOF && isspace(c)) c = getchar();if (c == EOF) return false;3 行未改动}*s = '\0';return true;}// 输出整数template <typename T>inline void write(T x) {if (x < 0) {putchar('-');6 行未改动x /= 10;} while (x);while (len--) putchar(tmp[len]);}// 输出字符串inline void write(const char *s) {while (*s) putchar(*s++);}// 输出换行inline void writeln() {putchar('\n');}// 输出整数并换行template <typename T>inline void writeln(T x) {write(x);putchar('\n');}// 输出字符串并换行inline void writeln(const char *s) {write(s);putchar('\n');}} // namespace FastIO```1234567891011121314151617181920212223242526272829303132333435363738395 行未改动45464748495051523 行未改动56575859606162633 行未改动67686970717273746 行未改动81828384858687888990919293949596979899100101102```cppnamespace FastIO {const int BUFFER_SIZE = 1 << 20;char in_buf[BUFFER_SIZE];char *in_ptr = in_buf;char *in_end = in_buf;char out_buf[BUFFER_SIZE];char *out_ptr = out_buf;inline void load() {in_end = in_buf + fread(in_buf, 1, BUFFER_SIZE, stdin);in_ptr = in_buf;}inline char getchar() {if (in_ptr == in_end) {load();if (in_ptr == in_end) return EOF;}return *in_ptr++;}inline void putchar(char c) {if (out_ptr == out_buf + BUFFER_SIZE) {fwrite(out_buf, 1, BUFFER_SIZE, stdout);out_ptr = out_buf;}*out_ptr++ = c;}inline void flush() {fwrite(out_buf, 1, out_ptr - out_buf, stdout);out_ptr = out_buf;}template <typename T>inline bool read(T &x) {x = 0;char c = getchar();bool negative = false;while (c != EOF && isspace(c)) c = getchar();if (c == EOF) return false;if (c == '-') {negative = true;5 行未改动}if (negative) x = -x;return true;}inline bool read(std::string &s) {s.clear();char c = getchar();while (c != EOF && isspace(c)) c = getchar();3 行未改动c = getchar();}return true;}inline bool read(char *s) {char c = getchar();while (c != EOF && isspace(c)) c = getchar();if (c == EOF) return false;3 行未改动}*s = '\0';return true;}template <typename T>inline void write(T x) {if (x < 0) {putchar('-');6 行未改动x /= 10;} while (x);while (len--) putchar(tmp[len]);}inline void write(const char *s) {while (*s) putchar(*s++);}inline void writeln() {putchar('\n');}template <typename T>inline void writeln(T x) {write(x);putchar('\n');}inline void writeln(const char *s) {write(s);putchar('\n');}}using namespace FastIO;```