#ABC198E. [ABC198E] Unique Color
[ABC198E] Unique Color
Score : points
Problem Statement
Given is a tree with vertices numbered through . The -th edge connects Vertex and Vertex . Vertex is painted in color (in this problem, colors are represented as integers).
Vertex is said to be good when the shortest path from Vertex to Vertex does not contain a vertex painted in the same color as Vertex , except Vertex itself.
Find all good vertices.
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print all good vertices as integers, in ascending order, using newline as a separator.
For example, the shortest path from Vertex to Vertex contains Vertices . Among them, only Vertex itself is painted in the same color as Vertex , so it is a good vertex. On the other hand, the shortest path from Vertex to Vertex contains Vertices , and Vertex is painted in the same color as Vertex , so Vertex is not a good vertex.