{"problem":{"name":"Unique Color","description":{"content":"Given is a tree with $N$ vertices numbered $1$ through $N$. The $i$\\-th edge connects Vertex $A_i$ and Vertex $B_i$. Vertex $i$ is painted in color $C_i$ (in this problem, colors are represented as in","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc198_e"},"statements":[{"statement_type":"Markdown","content":"Given is a tree with $N$ vertices numbered $1$ through $N$. The $i$\\-th edge connects Vertex $A_i$ and Vertex $B_i$. Vertex $i$ is painted in color $C_i$ (in this problem, colors are represented as integers).\nVertex $x$ is said to be **good** when the shortest path from Vertex $1$ to Vertex $x$ does not contain a vertex painted in the same color as Vertex $x$, except Vertex $x$ itself.\nFind all good vertices.\n\n## Constraints\n\n*   $2 \\leq N \\leq 10^5$\n*   $1 \\leq C_i \\leq 10^5$\n*   $1 \\leq A_i,B_i \\leq N$\n*   The given graph is a tree.\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$C_1$ $\\ldots$ $C_N$\n$A_1$ $B_1$\n$\\vdots$\n$A_{N-1}$ $B_{N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc198_e","tags":[],"sample_group":[["6\n2 7 1 8 2 8\n1 2\n3 6\n3 2\n4 3\n2 5","1\n2\n3\n4\n6\n\nFor example, the shortest path from Vertex $1$ to Vertex $6$ contains Vertices $1,2,3,6$. Among them, only Vertex $6$ itself is painted in the same color as Vertex $6$, so it is a good vertex.  \nOn the other hand, the shortest path from Vertex $1$ to Vertex $5$ contains Vertices $1,2,5$, and Vertex $1$ is painted in the same color as Vertex $5$, so Vertex $5$ is not a good vertex."],["10\n3 1 4 1 5 9 2 6 5 3\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10","1\n2\n3\n5\n6\n7\n8"]],"created_at":"2026-03-03 11:01:13"}}