求助lca部分
查看原帖
求助lca部分
407223
TulipeNoire楼主2022/5/13 19:10

应该是lca的问题:

inline int LCA(int x,int y) {
	int res=lca(x,y),res1=lca(x,root),res2=lca(y,root);
	if (res1==x&&res2!=root) return x;
	if (res2==y&&res1!=root) return y;
	if (lca(res,root)!=res) return res;
	return depth[res1]>depth[res2]?res1:res2;
}
2022/5/13 19:10
加载中...