Numbers to node
int tree [ n + 1 ] ; tree [ 1 ] = 10 ; tree [ 2 ] = 5 ; tree [ 3 ] = 11 ; tree [ 4 ] = 6 ; tree [ 5 ] = 8 ; int dp1 [ n + 1 ] , dp2 [ n + 1 ] ; memset ( dp1 , 0 , sizeof dp1 ) ; memset ( dp2 , 0 , sizeof dp2 ) ; dfs ( 1 , 1 , dp1 , dp2 , adj , tree ) ;