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

18749번 - Hit 스페셜 저지다국어

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

문제

Place at most n integer points on the number line in such a way that each of the given n segments [li, ri] contains at least one point, and the largest number of points contained inside one of the given segments is as small as possible.

입력

The first line contains a single integer t (1 ≤ t ≤ 105), denoting the number of test cases.

Each test case is described with an integer n (1 ≤ n ≤ 105), followed by n lines containing two integers li and ri each (−109 ≤ li < ri ≤ 109), denoting a segment containing points li, li + 1, . . . , ri. Segments may coincide.

The sum of n over all test cases does not exceed 105.

출력

For each test case, display the largest number of points inside one of the given segments in your placement, followed by the number of points you place k (1 ≤ k ≤ n), followed by k distinct integers xi (−109 ≤ xi ≤ 109), denoting the coordinates of the points you place.

제한

예제 입력 1

4
4
0 1
2 3
4 5
3 5
5
0 70
0 10
20 30
40 50
60 70
8
-1 7
-2 -1
-9 -7
-8 9
-9 -7
-2 4
-7 4
3 9
5
0 1
0 2
2 3
3 5
4 5

예제 출력 1

1 3 1 2 5
4 4 10 30 50 70
2 3 -9 -1 9
2 3 1 3 5

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 7: Gennady Korotkevich Contest 5 H번

Contest > Open Cup > 2019/2020 Season > Stage 11: Grand Prix of Gomel H번

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

출처

대학교 대회

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

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