树剖求调,AC on 1

P4114 Qtree1

@[yyrwlj](/user/965685) 改成这样,原因是必须让重链上 dfn 连续。 ```cpp void dfs2(int u, int fa, int Top) { top[u] = Top; dfn[u] = ++vis_cnt; if (big_son[u]) dfs2(big_son[u], u, Top); for (int i = h[u]; i; i = g[i].nxt) { int j = g[i].to; if (j == big_son[u]) num[dfn[j]] = g[i].e; if (j == fa || j == big_son[u]) continue; dfs2(j, u, j); num[dfn[j]] = g[i].e; } } ```
by Usada_Pekora @ 2023-12-28 19:10:52


@[Usada_Pekora](/user/434929) 这把眼瞎局 /bx
by yyrwlj @ 2023-12-28 19:17:17


|