彩色区间AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given positive integers $N$ and $M$. For each $j = 1, 2, \ldots, M$, you are given a pair of integers $(L_j, R_j)$ satisfying $1\leq L_j\leq R_j\leq N$.
给定正整数 $N$ 和 $M$。对于每个 $j = 1, 2, \ldots, M$,给定一对满足 $1\leq L_j\leq R_j\leq N$ 的整数 $(L_j, R_j)$。AI (CI翻译)
Consider a length-$N$ positive integer sequence $A = (A_1, A_2, \ldots, A_N)$ satisfying the following condition for all $j = 1, 2, \ldots, M$:
考虑一个长度为 $N$ 的正整数序列 $A = (A_1, A_2, \ldots, A_N)$,要求对于所有 $j = 1, 2, \ldots, M$,满足以下条件:AI (CI翻译)
$A_{L_j}, A_{L_j+1}, \ldots, A_{R_j}$are all distinct.
$A_{L_j}, A_{L_j+1}, \ldots, A_{R_j}$两两不同。
It can be proved that such a positive integer sequence $A$ always exists. Among all positive integer sequences $A$ satisfying the condition, output one that minimizes the value of $\max(A_1, A_2, \ldots, A_N)$.
可以证明,总是存在满足条件的正整数序列 $A$。在所有满足条件的正整数序列中,请输出一个使得 $\max(A_1, A_2, \ldots, A_N)$ 最小的序列。AI (CI翻译)
$T$ test cases are given; solve each of them.
共有 $T$ 组测试用例,请分别求解。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1\leq T\leq 10^5$$1\leq N\leq 2\times 10^5$$1\leq M\leq 2\times 10^5$$1\leq L_j \leq R_j\leq N$($1\leq j\leq M$)- All input values are integers.
- The sum of
$N$over all test cases is at most$2\times 10^5$. - The sum of
$M$over all test cases is at most$2\times 10^5$.
$1\leq T\leq 10^5$$1\leq N\leq 2\times 10^5$$1\leq M\leq 2\times 10^5$$1\leq L_j \leq R_j\leq N$($1\leq j\leq M$)- 所有输入值均为整数。
- 所有测试用例中
$N$的总和不超过$2\times 10^5$。 - 所有测试用例中
$M$的总和不超过$2\times 10^5$。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入给出,格式如下:AI (CI翻译)
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_TAI (CI翻译)
Each test case is given in the following format:
每组测试用例的格式如下:AI (CI翻译)
N M
L_1 R_1
L_2 R_2
\vdots
L_M R_M
N M
L_1 R_1
L_2 R_2
\vdots
L_M R_MAI (CI翻译)
Output
输出格式
AI (CI翻译)Output one line per test case. For each test case, output the elements, space-separated, of a positive integer sequence $A$ satisfying the condition that minimizes $\max(A_1, A_2, \ldots, A_N)$.
每组测试用例输出一行。对于每组测试用例,输出一个满足条件且使 $\max(A_1, A_2, \ldots, A_N)$ 最小的正整数序列 $A$ 的各个元素,元素之间用空格分隔。AI (CI翻译)
A_1 A_2 \ldots A_N
A_1 A_2 \ldots A_NAI (CI翻译)
If multiple such $A$ exist, any of them will be accepted.
如果有多个满足条件的 $A$,输出其中任意一个即可。AI (CI翻译)
样例
2
5 1
1 5
5 3
1 2
2 3
3 5
1 2 3 4 5
3 1 2 1 3
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。