AT_abc448_d [ABC448D] Integer-duplicated Path

Description

You are given a tree with $ N $ vertices numbered $ 1,2,\dots,N $ . The $ i $ -th edge connects vertices $ U_i $ and $ V_i $ . Each vertex $ i $ has an integer $ A_i $ written on it. Answer the following problem for all $ k=1,2,\dots,N $ . - Problem: Among the vertices on the simple path (a path that does not visit the same vertex more than once) from vertex $ 1 $ to vertex $ k $ , if there exist two distinct vertices with the same integer written on them, output `Yes`; otherwise, output `No`. - It can be proved that the simple path connecting two vertices on a tree is unique.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A_1 $ $ A_2 $ $ \dots $ $ A_N $ $ U_1 $ $ V_1 $ $ U_2 $ $ V_2 $ $ \vdots $ $ U_{N-1} $ $ V_{N-1} $

Output Format

Output $ N $ lines. The $ i $ -th line should contain the answer to the problem for $ k=i $ .

Explanation/Hint

### Sample Explanation 1 - For $ k=1 $ : the path from vertex $ 1 $ to vertex $ 1 $ contains only vertex $ 1 $ . Since the path consists of only one vertex, the answer is `No`. - For $ k=2 $ : the path from vertex $ 1 $ to vertex $ 2 $ contains vertices $ 1,2 $ , with integers $ 1,3 $ written on them respectively. Thus, the answer is `No`. - For $ k=3 $ : the path from vertex $ 1 $ to vertex $ 3 $ contains vertices $ 1,3 $ , with integers $ 1,2 $ written on them respectively. Thus, the answer is `No`. - For $ k=4 $ : the path from vertex $ 1 $ to vertex $ 4 $ contains vertices $ 1,3,4 $ , with integers $ 1,2,1 $ written on them respectively. Since vertices $ 1 $ and $ 4 $ on the path have the same integer $ 1 $ written on them, the answer is `Yes`. - For $ k=5 $ : the path from vertex $ 1 $ to vertex $ 5 $ contains vertices $ 1,3,5 $ , with integers $ 1,2,2 $ written on them respectively. Since vertices $ 3 $ and $ 5 $ on the path have the same integer $ 2 $ written on them, the answer is `Yes`. ### Constraints - All input values are integers. - $ 2 \le N \le 2 \times 10^5 $ - $ 1 \le A_i \le 10^9 $ - $ 1 \le U_i, V_i \le N $ - The given graph is a tree.