假如你求lca和一维数组用的是同一个欧拉序
查看原帖
假如你求lca和一维数组用的是同一个欧拉序
544756
xiaobing楼主2024/11/27 18:33

这两个欧拉序不一样!!!

void pre(int x) {
	dfn[++tot] = x;//求lca
	ft[x] = tot;
	dfn2[++tot2] = x;//求一维数组
	fst[x] = tot2;
	for (int i = head[x]; i; i = e[i].nxt) {
		int to = e[i].to;
		if (fa[x] == to)continue;
		fa[to] = x;
		depth[to] = depth[x] + 1;
		pre(to);
		dfn[++tot] = x;
	}
	if (x != 1)dfn2[++tot2] = x, scd[x] = tot2;
}
2024/11/27 18:33
加载中...