QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 512 MB 總分: 100

#3101. 事件跳跃 2

统计

在 IOI 公园,很快将举办 $N$ 场活动。活动编号从 $1$ 到 $N$。第 $i$ 场活动($1 \le i \le N$)将在时间 $L_i + 0.1$ 开始,并在时间 $R_i - 0.1$ 结束。其中 $L_i$ 和 $R_i$ 为整数。

JOI-kun 将参加其中的恰好 $K$ 场活动。禁止在活动开始后进入,或在活动结束前离开。我们忽略在活动地点之间移动所需的时间。

JOI-kun 希望参加编号较小的活动。更准确地说,令 $a_1, \dots, a_K$($1 \le a_1 < \dots < a_K \le N$)为 JOI-kun 将要参加的活动编号。那么 $(a_1, \dots, a_K)$ 应该是字典序最小的序列。在此,序列 $(a_1, \dots, a_K)$ 比另一个序列 $(b_1, \dots, b_K)$ 在字典序上更小,当且仅当存在 $j$($1 \le j \le K$)满足“对于所有 $1 \le \ell \le j - 1$,$a_\ell = b_\ell$”且“$a_j < b_j$”。

请编写一个程序,在给定活动信息和 JOI-kun 将要参加的活动数量 $K$ 的情况下,判断 JOI-kun 是否能够参加 $K$ 场活动。如果 JOI-kun 可以参加 $K$ 场活动,程序应计算出 JOI-kun 将参加的 $K$ 场活动。

输入格式

从标准输入读取以下数据。给定值均为整数。

$N \ K$ $L_1 \ R_1$ $\vdots$ $L_N \ R_N$

输出格式

如果 JOI-kun 无法参加 $K$ 场活动,输出一行包含 $-1$ 到标准输出。 如果 JOI-kun 可以参加 $K$ 场活动,输出 $K$ 行到标准输出。令 $a_1, \dots, a_K$($1 \le a_1 < \dots < a_K \le N$)为 JOI-kun 将要参加的活动编号。输出的第 $j$ 行($1 \le j \le K$)应包含 $a_j$。在此,$(a_1, \dots, a_K)$ 应该是字典序最小的序列。

数据范围

  • $1 \le N \le 100\,000$。
  • $1 \le K \le N$。
  • $1 \le L_i < R_i \le 1\,000\,000\,000$($1 \le i \le N$)。

子任务

  1. (7 分) $L_i \le L_{i+1}$($1 \le i \le N - 1$)。
  2. (1 分) $N \le 20$。
  3. (31 分) $N \le 3\,000$。
  4. (61 分) 无附加限制。

样例

样例输入 1

5 4
1 3
2 5
8 9
6 8
10 15

样例输出 1

1
3
4
5

说明 1

JOI-kun 参加恰好 4 场活动有两种方式: JOI-kun 参加活动 1, 3, 4, 5。 JOI-kun 参加活动 2, 3, 4, 5。 由于序列 $(1, 3, 4, 5)$ 在字典序上小于序列 $(2, 3, 4, 5)$,因此输出 1, 3, 4, 5。

样例输入 2

4 3
1 4
3 5
4 9
7 10

样例输出 2

-1

说明 2

由于 JOI-kun 不可能参加恰好 3 场活动,输出 -1。

样例输入 3

10 6
77412002 93858605
244306432 318243514
280338037 358494212
439397354 492065507
485779890 529132783
571714810 632053254
659767854 709114867
718405631 733610573
786950301 815106357
878719468 899999649

样例输出 3

1
2
4
6
7
8

说明 3

该样例输入满足所有子任务的限制。

样例输入 4

20 16
250732298 258217736
26470443 34965880
252620676 260043105
692063405 697656580
497457675 504191511
391372149 397942668
858168758 867389085
235756850 241022021
585764751 593366541
207824318 217052204
661682908 671226688
886273261 892279963
770109416 778960597
264372562 270395107
176883483 186662376
509929119 519063796
109491630 118520141
162731982 168101507
662727316 668317158
757072772 765493222

样例输出 4

1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.