시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 26 | 20 | 18 | 78.261% |
Rar the Cat has an array X of N positive integers. He is a teacher and he wants to give his students a homework based on his array. The students in his class had learnt the min function, and Rar would like to test them on this. He have already set M homework questions, and all of them are of this form:
min(Xi, Xj) = ?
Unfortunately, Rar has lost his array! Given the M homework questions, as well as the answer key, help Rar to reconstruct a possible array that matches all of his homework answers. Such an array is guaranteed to exist.
Your program must read from standard input.
The first line of the input will contain 2 numbers, N and M.
The next M lines of input will contain 3 numbers, Ai, Bi, and Ci. For all i = 1, 2, ..., M, min(XAi, XBi) = Ci.
Output N numbers in a single line (separated by spaces), the array X. If multiple solutions exist, all of them will be accepted. All elements of X must be between 1 and 109 (inclusive).
2 1 2 1 7
9 7
The reconstructed array satisfies the given constraints:
5 6 1 2 1 3 5 4 1 5 3 1 3 3 2 3 1 2 4 1
3 1 4 1 5
The reconstructed array satisfies the given constraints:
5 1 1 2 123
123 1000000000 3 4 26311337
The only condition for the array is that min(X1, X2) = 123, the rest of the array can be any value between 1 and 109.