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

19077번 - A Place For My Head 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB6611842.105%

문제

Artem has constructed a permutation $p$ of $n$ integers from 1ドル$ to $n$ during the last Jinotega beer party. Kostya tried to guess it, but had no success. Then Artem gave some hints to Kostya: for each $i = 1, \ldots, n,ドル he told him two integers $l_i \le r_i,ドル meaning that element $i$ is situated between positions $l_i$ and $r_i$ inclusively. Kostya is sure that the lexicographically smallest permutation satisfying these conditions is the one Artem has constructed. As it is too late, and Kostya's brain is not working as well as usually after several glasses of beer, you need to help him.

입력

The first line of input contains a positive integer $n$ (1ドル \le n \le 2 \cdot 10^5$), the length of the permutation.

Each of the next $n$ lines contain two integers $l_i$ and $r_i$ (1ドル \le l_i \le r_i \le n$).

출력

If it is impossible to reconstruct the permutation, print a line containing the integer $-1$.

Otherwise, print a line containing $n$ space-separated integers $p_1, p_2, \ldots, p_n$: the desired permutation.

제한

예제 입력 1

5
2 5
1 5
3 5
4 5
1 5

예제 출력 1

2 1 3 4 5

예제 입력 2

6
2 4
1 3
4 6
4 6
4 6
3 5

예제 출력 2

2 1 6 3 4 5

예제 입력 3

4
1 3
1 3
1 3
1 3

예제 출력 3

-1

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 5: Moscow IPT Contest A번

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

출처

대학교 대회

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

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