CF1297F.Movie Fan

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line contains an integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases in the input. The following are descriptions of the tt test cases.

The first line of each test case contains two integers nn and mm ( 1n21051 \le n \le 2 \cdot 10^5 , 1m1091 \le m \le 10^9 ) — the number of movies and the maximum number of movies that Polycarp can view per day.

In the next nn lines, the movies themselves are described, one per line, by a pair of integers aia_i , bib_i ( 1aibi1091 \le a_i \le b_i \le 10^9 ) — the first and last airing days for the ii -th movie.

It is guaranteed that the sum of the values nn for all test cases in the input does not exceed 21052 \cdot 10^5 .

输入格式

Print tt answers to given test cases in the order in which they appear in the input: the ii -th answer should consist of two lines. Print the integer dd in the first line of each test case answer:

  • d=0d=0 , if there is a schedule such that all movies are watched during airing,
  • d>0d>0 , if such a schedule does not exist — in this case, dd is equal to the minimum value of maximum among all the watching "delays" after the end of airing.

In the second line of the answer to each test case, print nn positive integers t1,t2,,tnt_1, t_2, \dots, t_n , where tit_i is the number of the day when Polycarp needs to watch the ii -th movie in the optimal schedule.

If there are several answers, print any of them.

输出格式

输入输出样例

  • 输入#1

    3
    7 2
    1 2
    1 3
    2 2
    2 3
    1 1
    2 3
    1 2
    5 3
    1 1
    1 1
    1 1
    1 1
    1 1
    6 1
    13 13
    31 31
    25 25
    12 12
    14 14
    10 10

    输出#1

    1
    1 3 2 3 1 4 2 
    1
    1 1 1 2 2 
    0
    13 31 25 12 14 10
首页