Problem L: 图的遍历
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:187
Solved:59
Description
题目描述
给出N个点,M条边的有向图,对于每个点v,求A(v)表示从点 v 出发,能到达的编号最大的点.
Input
输入格式
第1 行,2 个整数N, M。
接下来M行,每行2个整数U_i,V_i,表示边(U_i,V_i)。点用1, 2,.... ,N编号。
接下来M行,每行2个整数U_i,V_i,表示边(U_i,V_i)。点用1, 2,.... ,N编号。
Output
输出格式
N 个整数A(1),A(2),.... ,A(N)。
Sample Input Copy
4 3
1 2
2 4
4 3
Sample Output Copy
4 4 3 4