正文
增加 13 行删除 13 行
1234567895 行未改动15161718192021222394 行未改动11811912012112212312412512634 行未改动161162163164165166167168169103 行未改动全部展开27327427527627727827928028118 行未改动3003013023033043053063073085 行未改动31431531631731831932032132277 行未改动400401402403404405406407408409410104 行未改动全部展开51551651751851952052152252310 行未改动534535536537538539540541542139 行未改动全部展开68268368468568668768868969021 行未改动712713714715716717718719720114 行未改动全部展开# 以下代码均为LCT~~LCT专题???~~# QTREE 1树链剖分 or LCT 板子没啥可说的,这题 LCT 跑的还没树链剖分 + 线段树快$code$5 行未改动rg char ch = getchar();rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 2e5 + 5;int id[N];int f[N], son[N][2], maxi[N], cnt, v[N], lazy[N], g[N];94 行未改动}scanf("%s", s);}}signed main(){work();//int T = read();//while(T--) work();34 行未改动rg char ch = getchar();rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 2e5 + 5;int id[N];int f[N], son[N][2], sum[N], cnt, v[N], lazy[N], g[N], sz[N], del[N], back[N];103 行未改动全部展开}scanf("%s", s);}}signed main(){int T = read();while(T--) work();return 0;18 行未改动rg char ch = getchar();rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 2e5 + 5;int id[N];int f[N], son[N][2], find1[N], find2[N], cnt, lazy[N], del[N];5 行未改动inline void up(int p){if(find1[ls]) find1[p] = find1[ls];else if(del[p]) find1[p] = p;else find1[p] = find1[rs];if(find2[rs]) find2[p] = find2[rs];else if(del[p]) find2[p] = p;else find2[p] = find2[ls];}77 行未改动del[x] ^= 1;up(x);}}}signed main(){work();return 0;}104 行未改动全部展开x = read(), y = read();add(x, y); add(y, x);}memset(lmn, 0x3f, sizeof lmn);memset(rmn, 0x3f, sizeof rmn);dfs(1);m = read();int op, x;while(m--){10 行未改动splay(x);printf("%d\n", rmn[x] >= inf ? -1 : rmn[x]);}}return 0;}```139 行未改动全部展开col[x] ^= 1;lct[col[x]].link(x);}}return 0;}```21 行未改动rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 1e5 + 5;int head[N], nxt[N << 1], ver[N << 1], tot;int fa[N], col[N];inline void add(int x, int y){114 行未改动全部展开1234567895 行未改动15161718192021222394 行未改动11811912012112212312412512634 行未改动161162163164165166167168169103 行未改动全部展开27327427527627727827928028118 行未改动3003013023033043053063073085 行未改动31431531631731831932032132277 行未改动400401402403404405406407408409410104 行未改动全部展开51551651751851952052152252310 行未改动534535536537538539540541542139 行未改动全部展开68268368468568668768868969021 行未改动712713714715716717718719720114 行未改动全部展开# 以下代码均为LCT~~LCT专题???~~# QTREE 1树链剖分 or LCT 板子没啥可说的,这题 LCT 跑的还没树链剖分 + 线段树快$code$5 行未改动rg char ch = getchar();rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 2e5 + 5;int id[N];int f[N], son[N][2], maxi[N], cnt, v[N], lazy[N], g[N];94 行未改动}scanf("%s", s);}}signed main(){work();//int T = read();//while(T--) work();34 行未改动rg char ch = getchar();rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 2e5 + 5;int id[N];int f[N], son[N][2], sum[N], cnt, v[N], lazy[N], g[N], sz[N], del[N], back[N];103 行未改动全部展开}scanf("%s", s);}}signed main(){int T = read();while(T--) work();return 0;18 行未改动rg char ch = getchar();rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 2e5 + 5;int id[N];int f[N], son[N][2], find1[N], find2[N], cnt, lazy[N], del[N];5 行未改动inline void up(int p){if(find1[ls]) find1[p] = find1[ls];else if(del[p]) find1[p] = p;else find1[p] = find1[rs];if(find2[rs]) find2[p] = find2[rs];else if(del[p]) find2[p] = p;else find2[p] = find2[ls];}77 行未改动del[x] ^= 1;up(x);}}}signed main(){work();return 0;}104 行未改动全部展开x = read(), y = read();add(x, y); add(y, x);}memset(lmn, 0x3f, sizeof lmn);memset(rmn, 0x3f, sizeof rmn);dfs(1);m = read();int op, x;while(m--){10 行未改动splay(x);printf("%d\n", rmn[x] >= inf ? -1 : rmn[x]);}}return 0;}```139 行未改动全部展开col[x] ^= 1;lct[col[x]].link(x);}}return 0;}```21 行未改动rg int x = 0, f = 0;while(! isdigit(ch)) f |= (ch == '-'), ch = getchar();while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? -x : x;}const int N = 1e5 + 5;int head[N], nxt[N << 1], ver[N << 1], tot;int fa[N], col[N];inline void add(int x, int y){114 行未改动全部展开