正文
增加 27 行删除 27 行
76 行未改动77787980818283848586878889909192939495969798991001011021031041051061071081091101111126 行未改动11912012112212312412512612712812913013113213313413513613713813914014114214314414514614714820 行未改动1691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072 行未改动2102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462 行未改动2492502512522532542552562572582592602612622632642652662672682692702712722732742752762 行未改动76 行未改动char ibuf[BUFSIZE], obuf[BUFSIZE];char *ip1 = ibuf, *ip2 = ibuf;char *op1 = obuf;int precision;ALWAYS_INLINE char getchar() {if (ip1 == ip2) {ip1 = ibuf;ip2 = ibuf + fread(ibuf, 1, BUFSIZE, stdin);if (ip1 == ip2) return EOF;}return *ip1++;}ALWAYS_INLINE void putchar(char c) {if (op1 == obuf + BUFSIZE) {fwrite(obuf, 1, BUFSIZE, stdout);op1 = obuf;}*op1++ = c;}public:FastIO() : precision(6) {memset(ibuf, 0, sizeof(ibuf));memset(obuf, 0, sizeof(obuf));}~FastIO() {fwrite(obuf, 1, op1 - obuf, stdout);}template<typename T>ALWAYS_INLINE void read(T &x) {x = 0; T f = 1;char c = getchar();6 行未改动c = getchar();}x *= f;}template<typename T>ALWAYS_INLINE void write(T x) {if (x < 0) {putchar('-');x = -x;}if (x > 9) write(x / 10);putchar(x % 10 + '0');}ALWAYS_INLINE void read(char *s) {char c = getchar();while (c <= ' ') c = getchar();while (c > ' ') *s++ = c, c = getchar();*s = '\0';}ALWAYS_INLINE void write(const char *s) {while (*s) putchar(*s++);}ALWAYS_INLINE void set_precision(int p) {precision = p;}} IO;20 行未改动class MemoryPool {private:T pool[SIZE];size_t index;public:MemoryPool() : index(0) {}ALWAYS_INLINE T* allocate() {return &pool[index++];}ALWAYS_INLINE void clear() {index = 0;}ALWAYS_INLINE size_t size() const {return index;}};// 快速排序(特定情况使用)template<typename T>ALWAYS_INLINE void quick_sort(T *arr, int l, int r) {if (l >= r) return;T pivot = arr[(l + r) >> 1];int i = l - 1, j = r + 1;while (i < j) {do i++; while (arr[i] < pivot);do j--; while (arr[j] > pivot);if (i < j) swap(arr[i], arr[j]);}quick_sort(arr, l, j);quick_sort(arr, j + 1, r);}2 行未改动// 终极IO优化ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);// 设置浮点数精度(如果需要)cout.precision(10);cout << fixed;// 关闭C流同步std::ios_base::sync_with_stdio(false);// 你的代码开始return 0;}// 预编译常用数据结构namespace FastDS {// 快速并查集class UnionFind {private:vector<int> parent, rank;public:UnionFind(int n) : parent(n), rank(n, 0) {for (int i = 0; i < n; i++) parent[i] = i;}ALWAYS_INLINE int find(int x) {return parent[x] == x ? x : parent[x] = find(parent[x]);}ALWAYS_INLINE void unite(int x, int y) {x = find(x), y = find(y);if (x == y) return;if (rank[x] < rank[y]) {2 行未改动parent[y] = x;if (rank[x] == rank[y]) rank[x]++;}}ALWAYS_INLINE bool same(int x, int y) {return find(x) == find(y);}};// 快速前缀和template<typename T>class PrefixSum {private:vector<T> pre;public:PrefixSum(const vector<T> &arr) {pre.resize(arr.size() + 1);for (size_t i = 0; i < arr.size(); i++) {pre[i + 1] = pre[i] + arr[i];}}ALWAYS_INLINE T query(int l, int r) {return pre[r + 1] - pre[l];}};2 行未改动76 行未改动77787980818283848586878889909192939495969798991001011021031041051061071081091101111126 行未改动11912012112212312412512612712812913013113213313413513613713813914014114214314414514614714820 行未改动1691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072 行未改动2102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462 行未改动2492502512522532542552562572582592602612622632642652662672682692702712722732742752762 行未改动76 行未改动char ibuf[BUFSIZE], obuf[BUFSIZE];char *ip1 = ibuf, *ip2 = ibuf;char *op1 = obuf;int precision;ALWAYS_INLINE char getchar() {if (ip1 == ip2) {ip1 = ibuf;ip2 = ibuf + fread(ibuf, 1, BUFSIZE, stdin);if (ip1 == ip2) return EOF;}return *ip1++;}ALWAYS_INLINE void putchar(char c) {if (op1 == obuf + BUFSIZE) {fwrite(obuf, 1, BUFSIZE, stdout);op1 = obuf;}*op1++ = c;}public:FastIO() : precision(6) {memset(ibuf, 0, sizeof(ibuf));memset(obuf, 0, sizeof(obuf));}~FastIO() {fwrite(obuf, 1, op1 - obuf, stdout);}template<typename T>ALWAYS_INLINE void read(T &x) {x = 0; T f = 1;char c = getchar();6 行未改动c = getchar();}x *= f;}template<typename T>ALWAYS_INLINE void write(T x) {if (x < 0) {putchar('-');x = -x;}if (x > 9) write(x / 10);putchar(x % 10 + '0');}ALWAYS_INLINE void read(char *s) {char c = getchar();while (c <= ' ') c = getchar();while (c > ' ') *s++ = c, c = getchar();*s = '\0';}ALWAYS_INLINE void write(const char *s) {while (*s) putchar(*s++);}ALWAYS_INLINE void set_precision(int p) {precision = p;}} IO;20 行未改动class MemoryPool {private:T pool[SIZE];size_t index;public:MemoryPool() : index(0) {}ALWAYS_INLINE T* allocate() {return &pool[index++];}ALWAYS_INLINE void clear() {index = 0;}ALWAYS_INLINE size_t size() const {return index;}};// 快速排序(特定情况使用)template<typename T>ALWAYS_INLINE void quick_sort(T *arr, int l, int r) {if (l >= r) return;T pivot = arr[(l + r) >> 1];int i = l - 1, j = r + 1;while (i < j) {do i++; while (arr[i] < pivot);do j--; while (arr[j] > pivot);if (i < j) swap(arr[i], arr[j]);}quick_sort(arr, l, j);quick_sort(arr, j + 1, r);}2 行未改动// 终极IO优化ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);// 设置浮点数精度(如果需要)cout.precision(10);cout << fixed;// 关闭C流同步std::ios_base::sync_with_stdio(false);// 你的代码开始return 0;}// 预编译常用数据结构namespace FastDS {// 快速并查集class UnionFind {private:vector<int> parent, rank;public:UnionFind(int n) : parent(n), rank(n, 0) {for (int i = 0; i < n; i++) parent[i] = i;}ALWAYS_INLINE int find(int x) {return parent[x] == x ? x : parent[x] = find(parent[x]);}ALWAYS_INLINE void unite(int x, int y) {x = find(x), y = find(y);if (x == y) return;if (rank[x] < rank[y]) {2 行未改动parent[y] = x;if (rank[x] == rank[y]) rank[x]++;}}ALWAYS_INLINE bool same(int x, int y) {return find(x) == find(y);}};// 快速前缀和template<typename T>class PrefixSum {private:vector<T> pre;public:PrefixSum(const vector<T> &arr) {pre.resize(arr.size() + 1);for (size_t i = 0; i < arr.size(); i++) {pre[i + 1] = pre[i] + arr[i];}}ALWAYS_INLINE T query(int l, int r) {return pre[r + 1] - pre[l];}};2 行未改动