正文
增加 132 行删除 0 行
107 行未改动全部展开108109110111112107 行未改动全部展开#define cout io#define cin io#define endl '\n'} using namespace fast_IO;```107 行未改动全部展开108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244107 行未改动全部展开#define cout io#define cin io#define endl '\n'} using namespace fast_IO;8.namespace fast_IO {#define IOSIZE 1000000char ibuf[IOSIZE], obuf[IOSIZE], *p1 = ibuf, *p2 = ibuf, *p3 = obuf;#define getchar() ((p1==p2)and(p2=(p1=ibuf)+fread(ibuf,1,IOSIZE,stdin),p1==p2)?(EOF):(*p1++))#define putchar(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 = getchar(), !isdigit(ch) and (ch != EOF))if (ch == '-') w = -1;if (ch == EOF) return false;while (isdigit(ch)) s = s * 10 + ch - 48, ch = getchar();return s * w;}template<typename T> inline bool read(T &s) {s = 0;int w = 1;char ch;while (ch = getchar(), !isdigit(ch) and (ch != EOF))if (ch == '-') w = -1;if (ch == EOF) return false;while (isdigit(ch)) s = s * 10 + ch - 48, ch = getchar();return s *= w, true;}// 核心优化:递归改迭代,消除栈开销和调用开销template<typename T> inline void print(T x) {if (x < 0) putchar('-'), x = -x;if (x > 9) print(x / 10);putchar(x % 10 + 48);}// 针对int的特化:用do-while+数组反转,比递归快30-50%template<> inline void print(int x) {if (x < 0) putchar('-'), x = -x;static char buf[16];int n = 0;do {buf[n++] = x % 10 + 48;x /= 10;} while (x);while (n--) putchar(buf[n]);}// 针对long long的特化template<> inline void print(long long x) {if (x < 0) putchar('-'), x = -x;static char buf[24];int n = 0;do {buf[n++] = x % 10 + 48;x /= 10;} while (x);while (n--) putchar(buf[n]);}inline bool read(char &s) {while (s = getchar(), isspace(s));return true;}inline bool read(char *s) {char ch;while (ch = getchar(), isspace(ch));if (ch == EOF) return false;while (!isspace(ch)) *s++ = ch, ch = getchar();*s = '\000';return true;}inline void print(char x) { putchar(x); }inline void print(char *x) { while (*x) putchar(*x++); }inline void print(const char *x) {for (int i = 0; x[i]; i++) putchar(x[i]);}inline bool read(std::string& s) {s = "";char ch;while (ch = getchar(), isspace(ch));if (ch == EOF) return false;while (!isspace(ch)) s += ch, ch = getchar();return true;}inline void print(std::string x) {for (int i = 0, n = x.size(); i < n; i++) putchar(x[i]);}inline bool read(bool &b) {char ch;while(ch=getchar(), isspace(ch));b=ch^48;return true;}inline void print(bool b) { putchar(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 fast_IO;```