会构建虚树之后就是noip提高组的题目了稍微难一点的是求代价和,只要注意按一个方向避免重复计算贡献即可 ; type node=record po,next:longint; end; ..] of longint; e:..] of node; f:..] of int64; v:..] of boolean; anc:..,..] of longint; ans2,ans3,z,t,h,i,len,n,m,s,j,x,y:longint; dis,ans1:int64; procedure…