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

33298번 - Scheduling 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB112218.182%

문제

Your boss made you find a valid schedule for his meetings. He has $n$ meetings, where the $i$-th meeting has to start and end in the time interval $[\ell_i, r_i],ドル where time is measured in hours. Each meeting takes exactly one hour, and your boss obviously cannot attend two meetings at the same time.

As a competitive programmer, you have already solved this classical scheduling problem countless times, and this time, you finally notice that it is completely unrealistic. How can one person attend over a hundred thousand meetings at different places without any time to travel between them and without taking any breaks either? There is no way every meeting takes exactly one hour -- speaking from experience -- and there will surely be meetings that start late because someone is running late.

These deep-rooted philosophical questions may be a big problem for humanity, but since you do not have to attend these meetings yourself, you simply do not care enough to solve all of them. However, impressing your boss will certainly be worth it for you, so you try to at least improve the schedule a little bit.

Find any schedule where there is at least one hour between every pair of meetings or report that there is none. Surely this is just one insignificant change to the classical problem, right?

입력

Each test contains multiple test cases. The first line of input contains a single integer $t$ (1ドル \leq t \leq 10^5$) --- the number of test cases. The description of the test cases follows.

The first line of each test case contains one integer $n$ (1ドル \leq n \leq 2 \cdot 10^5$) --- the number of meetings.

The next $n$ lines each contain two integers $\ell_i$ and $r_i$ (1ドル \leq \ell_i < r_i \leq 10^6$) --- the time interval in hours the $i$-th meeting has to start and end in.

The sum of $n$ over all test cases does not exceed 2ドル \cdot 10^5$.

출력

If there is no valid schedule, output $-1$ in a single line. Otherwise, output $n$ integers $a_i$ in a single line where $a_i$ is the start time of the $i$-th meeting.

제한

예제 입력 1

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

예제 출력 1

1 5 3
-1
-1
4 2

노트

In the first test case, the first meeting starts at the start of hour 1ドル$ and goes on for one hour until the start of hour 2ドル$. After that, your boss takes a break of one hour until he attends the third meeting from the start of hour 3ドル$ to 4ドル$. Then, he takes another one hour break until he finally attends the second meeting, which happens from the start of hour 5ドル$ to 6ドル$.

Note that it is not possible to start the third meeting at the start of hour 4ドル$ as this meeting would end at 5ドル$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 5: Der Kontest G번

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

출처

대학교 대회

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

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