| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 7 | 6 | 4 | 80.000% |
The Olympic football tournament has started and, of course, France is going to win by a landslide, thus killing all the suspense. Or is it? Until now, only ties happened: not very exciting...
To hype the event, you would like every remaining match not to be a tie, and among all such configurations, you would like to find one which minimises the difference between the best score and the worst score. Remember that the score of a team is the number of its won matches minus its lost matches.
Given the list of remaining matches, find such an optimal configuration of matches.
The first line contains two space-separated integers $N$ and $M$; $N$ is the number of teams, and $M$ is the number of remaining matches. This line is followed by $M$ lines: the $k$th such line contains two space-separated integers $x_k$ and $y_k,ドル indicating that the $x_k$th team has yet to play against the $y_k$th team during the $k$th match.
The output should contain $M$ lines. The $k$th such line should contain a single integer: the index of the team winning the $k$th match (which should be equal to either $x_k$ or $y_k$).
4 4 1 4 1 3 2 3 2 4
4 1 3 2
3 4 1 3 1 3 1 3 1 3
3 1 3 1
5 4 1 2 2 3 1 3 4 5
1 2 3 4