n is good if it satisfies the following constraint:
Given a tree with n n vertices where vertex r r is the root, we say a permutation p_1, p_2, cdots, p_n p 1 ,p 2 ,⋯,p n of n n is good if it satisfies the following constraint: Let a_x a x be the index of x x in the permutation (That is, p_{a_x} = x p a x =x). For all 1 le u, v le n 1≤u,v≤n, if vertex u u is an ancestor of vertex v v in the tree, then a_u < a_v a u
标签: HBC236069旗鼓相当的对手 数据结构 树 DSU on treePermutation on Tree题解