JZOJ5257. 小X的佛光(2017.8B组)

Description Input Output Sample Input 3 3 1 1 2 2 3 1 2 3 1 1 3 3 1 3 Sample Output 1 1 3 Data Constraint 想法: 暴力的LCA很多分 其实答案=(jl(x,y)+jl(y,z)-jl(x,z))/2+1 jl(x,y)=len[x]+len[y]-len[lca]*2; len为某个点的深度,
相关文章
相关标签/搜索