atcoder#AGC012B. [AGC012B] Splatter Painting
[AGC012B] Splatter Painting
Score : points
Problem Statement
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of vertices numbered through , and edges. Initially, all the vertices are painted in color . The -th edge bidirectionally connects two vertices and . The length of every edge is .
Squid performed operations on this graph. In the -th operation, he repaints all the vertices within a distance of from vertex , in color .
Find the color of each vertex after the operations.
Constraints
- and are all integers.
- There are no self-loops or multiple edges in the given graph.
Partial Score
- points will be awarded for passing the testset satisfying .
Input
Input is given from Standard Input in the following format:
Output
Print the answer in lines. In the -th line, print the color of vertex after the operations.
7 7
1 2
1 3
1 4
4 5
5 6
5 7
2 3
2
6 1 1
1 2 2
2
2
2
2
2
1
0
Initially, each vertex is painted in color . In the first operation, vertices and are repainted in color . In the second operation, vertices , , , and are repainted in color .
14 10
1 4
5 7
7 11
4 10
14 7
14 3
6 14
8 11
5 13
8 3
8
8 6 2
9 7 85
6 9 3
6 7 5
10 3 1
12 9 4
9 6 6
8 2 3
1
0
3
1
5
5
3
3
6
1
3
4
5
3
The given graph may not be connected.