版本比较
温暖会指引我们前行,真的吗,真的吗,真的吗
正文
增加 14 行删除 14 行
29 行未改动30313233343534353637383923 行未改动6364656667686768697071729 行未改动8283848586878889908687888990919293949593949596979798999910010110210359 行未改动29 行未改动 #define ion bw(20) char i[ion], o[ion], *icl = i, *icr = i, *oc = o; char gc() { return (icl == icr && (icr = (icl = i) + fread(i, 1, ion, stdin), icl == icr)) ? EOF : *icl++; } void pc(char c) { if (oc - o == ion) fwrite(o, 1, ion, stdout), oc = o; *oc++ = c; } void rd(auto &x) { char c; int f = 1; x = 0; while (c = gc(), c < '0' || c > '9') if (c == '-') f = -1; while ('0' <= c && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = gc(); x *= f; } void pr(auto x) { int a[64], p = 0; if (x < 0) x = -x, pc('-'); do a[p++] = x % 10; while (x /= 10); while (p--) pc(a[p] + '0'); } void rd(auto &x) { char c; int f = 1; x = 0; while (c = gc(), c < '0' || c > '9') if (c == '-') f = -1; while ('0' <= c && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = gc(); x *= f; } void pr(auto x) { int a[64], p = 0; if (x < 0) x = -x, pc('-'); do a[p++] = x % 10; while (x /= 10); while (p--) pc(a[p] + '0'); } IO& operator>>(char &c) { return c = gc(), *this; } IO& operator<<(char c) { return pc(c), *this; } IO& operator<<(const char *c) { while (*c) pc(*c++); return *this; } IO& operator>>(auto &x) { return rd(x), *this; }23 行未改动 int son[N][2], siz[N], fa[N], vlen[N], vtem[N], slen[N], stem[N], sid[N], tag[N], tot = 0; #define dir(u) (son[fa[u]][1] == u) #define irt(u) (fa[u] == 0 || (son[fa[u]][0] != u && son[fa[u]][1] != u)) void modify(int u) { swap(son[u][0], son[u][1]), tag[u] ^= 1; } void up(int u) { siz[u] = siz[son[u][0]] + siz[son[u][1]] + 1; void up(int u) { siz[u] = siz[son[u][0]] + siz[son[u][1]] + 1; slen[u] = slen[son[u][0]] + slen[son[u][1]] + vlen[u]; stem[u] = vtem[u], sid[u] = u; if (son[u][0] && stem[u] > stem[son[u][0]]) stem[u] = stem[son[u][0]], sid[u] = sid[son[u][0]]; if (son[u][1] && stem[u] > stem[son[u][1]]) stem[u] = stem[son[u][1]], sid[u] = sid[son[u][1]];9 行未改动 } void splay(int u) { all(u); for (int v = fa[u]; !irt(u); rotate(u), v = fa[u]) if (!irt(v)) rotate(dir(u) == dir(v) ? v : u); } void access(int u) { for (int v = 0; u; v = u, u = fa[u]) splay(u), son[u][1] = v, up(u); } void mkrt(int u) { access(u), splay(u), modify(u); } int frt(int u) { access(u), splay(u); } void access(int u) { for (int v = 0; u; v = u, u = fa[u]) splay(u), son[u][1] = v, up(u); } void mkrt(int u) { access(u), splay(u), modify(u); } int frt(int u) { access(u), splay(u); while (son[u][0]) u = son[u][0], down(u); splay(u); return u; } void split(int u, int v) { mkrt(u), access(v), splay(v); } return u; } void split(int u, int v) { mkrt(u), access(v), splay(v); } void link(int u, int v) { mkrt(u); if (frt(v) != u) fa[u] = v; } void cut(int u, int v) { void cut(int u, int v) { split(u, v); if (son[v][0] == u && !son[u][1]) son[v][0] = fa[u] = 0, up(v); if (son[v][0] == u && !son[u][1]) son[v][0] = fa[u] = 0, up(v); } pii ask(int u, int v) { split(u, v); return make_pair(stem[v], sid[v]); } int length(int u, int v) { split(u, v); return slen[v]; } }59 行未改动