6 2 7 1 8 2 8 1 2 3 6 3 2 4 3 2 5
1 2 3 4 6 For 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. On 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 3 1 4 1 5 9 2 6 5 3 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
1 2 3 5 6 7 8
{
"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 in...",
"is_translate": false,
"language": "English"
}
]
}