HBC236069旗鼓相当的对手,数据结构,树,DSU on treePermutation on Tree题解 (givenatreewithnnvertices)

季陌殇 基本结构 68 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
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题解