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题解
        		        	    	
 
    		 
   			
    		 
 
                 
 
                ![HBC214364Gold,枚举小游戏题解
(初中数学,a[j]=x+1=x-1) HBC214364Gold,枚举小游戏题解
(初中数学,a[j]=x+1=x-1)](https://www.xxstcz.com/zb_users/cache/thumbs/02d263d42d31a074ceb613838114629b-320-200-1.jpeg) 
 
                 
 
                 
 
                