版本比较
题解:CF1109F Sasha and Algorithm of Silence's Sounds
正文
增加 9 行删除 9 行
31 行未改动32333435363736373839404132 行未改动7475767778798081828384787980818283848586878874 行未改动31 行未改动 #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; }32 行未改动 if (!irt(v)) son[w][dir(v)] = u; fa[u] = w, son[v][d] = son[u][d ^ 1]; if (son[u][d ^ 1]) fa[son[u][d ^ 1]] = v; son[u][d ^ 1] = v, fa[v] = u, up(v), up(u); } 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 mak(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); return splay(u), u; } void split(int u, int v) { mak(u), access(v), splay(v); } void link(int u, int v) { mak(u); if (frt(v) != u) fa[u] = v; } } 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 mak(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); return splay(u), u; } void split(int u, int v) { mak(u), access(v), splay(v); } void link(int u, int v) { mak(u); if (frt(v) != u) fa[u] = v; } void cut(int u, int v) { mak(u); if (frt(v) == u && fa[v] == u && !son[v][0]) son[u][1] = fa[v] = 0, up(u); } } namespace sgt { // 线段树板子 #define ls (u << 1) #define rs (ls | 1)74 行未改动