P10733 [NOISG 2019 Prelim] Lost Array
Background
Translated from [NOISG2019 Prelim B.Lost Array](https://github.com/noisg/sg_noi_archive/blob/master/2019_prelim/).
**This problem uses Special Judge. Any answer that satisfies the conditions will be considered correct.**
Description
Given $M$ relations of the form $\min (X_{A_i}, X_{B_i}) = C_i$, construct an array $X$ of length $N$ such that every number in the array is between $1$ and $10^9$, and the array satisfies all relations.
It is guaranteed that such an array exists.
Input Format
The first line contains two integers $N, M$.
The next $M$ lines each contain three numbers $A_i, B_i, C_i$.
Output Format
Output one line with $N$ integers, representing the array $X$ you construct.
Explanation/Hint
### Sample #1 Explanation
Clearly, $\min (X_2, X_1) = \min (9, 7) = 7$, which satisfies the conditions.
### Sample #3 Explanation
The original statement did not include this sample, but it exists in the testdata.
The first constraint is $\min (X_1, X_2) = 1$. In fact, all constraints are the same as this one.
### Sample #4 Explanation
The only constraint is $\min (X_1, X_2) = 123$. The other numbers can be any values between $1$ and $10^9$.
### Constraints
| $\text{Subtask}$ | Score | Special Property |
| :----------: | :----------: | :----------: |
| $0$ | $0$ | Samples |
| $1$ | $5$ | $N = 2, M = 1$ |
| $2$ | $6$ | $M \leq 3$ |
| $3$ | $20$ | $N, M \leq 1000$ |
| $4$ | $21$ | $C_i \leq 10, N \leq 5$ |
| $5$ | $48$ | None |
For $100\%$ of the data:
- $1 \leq N, M \leq 10^5$.
- $1 \leq A_i, B_i \leq N$.
- $A_i \neq B_i$.
- $1 \leq C_i \leq 10^9$.
Translated by ChatGPT 5