Logo
(追記) (追記ここまで)

31449번 - Close scores 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB76480.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$).

제한

  • 2ドル \le N \le 100,円 000$
  • 1ドル \le M \le 100,円 000$
  • 1ドル \le x_k < y_k ⩽ N$ for all $k \le M$

예제 입력 1

4 4
1 4
1 3
2 3
2 4

예제 출력 1

4
1
3
2

예제 입력 2

3 4
1 3
1 3
1 3
1 3

예제 출력 2

3
1
3
1

예제 입력 3

5 4
1 2
2 3
1 3
4 5

예제 출력 3

1
2
3
4

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2023-2024 연습 세션 PB번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /