Vjudge https://vjudge.net/problem/AtCoder-2362 原网址 http://agc012.contest.atcoder.jp/tasks/agc012_b
Problem Statement
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices ai and bi. The length of every edge is 1.
Squid performed Q operations on this graph. In the i-th operation, he repaints all the vertices within a distance of di from vertex vi, in color ci.
Find the color of each vertex after the Q operations.
Constraints
1≤N,M,Q≤105 1≤ai,bi,vi≤N ai≠bi 0≤di≤10 1≤ci≤10^5 di and ci are all integers. There are no self-loops or multiple edges in the given graph.
Input
Input is given from Standard Input in the following format:
N M a1 b1 : aM bM Q v1 d1 c1 : vQ dQ cQ
The given graph may not be connected.
Output
Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.
Samples
No.InputOutput17 71 21 31 44 55 65 72 326 1 11 2 22222210214 101 45 77 114 1014 714 36 148 115 138 388 6 29 7 856 9 36 7 510 3 112 9 49 6 68 2 310315533613453