FJ's N (1 ≤ N ≤ 10,000) cows conveniently indexed 1..N are standing in a line. Each cow has a positive integer height (which is a bit of secret). You are told only the height H (1 ≤ H ≤ 1,000,000) of the tallest cow along with the index I of that cow. FJ has made a list of R (0 ≤ R ≤ 10,000) lines of the form "cow 17 sees cow 34". This means that cow 34 is at least as tall as cow 17, and that every cow between 17 and 34 has a height that is strictly smaller than that of cow 17. For each cow from 1..N, determine its maximum possible height, such that all of the information given is still correct. It is guaranteed that it is possible to satisfy all the constraints.
FJ 的 N (1 ≤ N ≤ 10,000) 头牛按 1~N 编号排成一列,每头牛的高度为正整数。已知最高的牛高度为 H (1 ≤ H ≤ 1,000,000),编号为 I。 FJ 给出了 R (0 ≤ R ≤ 10,000) 条关系,格式为「牛 A 能看到牛 B」,含义是:牛 B 的高度至少和牛 A 一样高,且 A 和 B 之间的所有牛的高度都严格小于牛 A 的高度。 要求在满足所有约束的前提下,求出每头牛的最大可能高度,题目保证存在合法解。
9 3 5 5
1 3
5 3
4 3
3 7
9 8
5
4
5
3
4
4
5
5
5
输入说明:共 9 头牛,第 3 头是最高的,高度为 5。