赛后补C题,这题型怎么越看越像虚树呢,然后试着用虚树+两次dfs找直径 AC了 将相同势力的点拿出来建虚树,然后树上找直径即可。但是这树没说根,我们假设1为根,找直径的时候特判一下1节点就可以了。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll inf=0x3f3f3f3; const int N=2e5+10; int dfn[N],numdfn; int n,max_deep; int a[N]; /* lca部分 */ struct LCA { int head[N],d...