QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 10

#6087. 暴风雪

统计

正如往常一样,冬天让道路维护人员措手不及。在拜特格罗德(Bajtogród),暴风雪肆虐,主干道急需清理积雪。

危机处理小组负责这项工作,他们拥有 $m$ 台除雪车,编号从 1 到 $m$。每台除雪车被分配了一个连续的道路片段进行清理。两个片段可能会重叠,但没有任何一个片段完全包含在另一个片段中。这些片段不需要覆盖整条道路(道路的某些部分可能位于隧道中,不需要清理)。

不幸的是,道路维护人员刚刚开始罢工。危机处理小组的领导层只说服了一名操作员工作,他必须负责操作所有的机器。现在需要确定除雪车的出发顺序。规定如下:每次操作员都会选择剩余待清理道路长度最短的除雪车(只需确保每段道路被清理一次即可,因此除雪车不需要清理之前已被其他除雪车清理过的部分)。如果存在平局,操作员将选择编号较小的除雪车。

输入格式

输入的第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 10^9$, $1 \le m \le 300\,000$),分别表示道路的长度和除雪车的数量。接下来的 $m$ 行描述了各台除雪车,按编号递增顺序排列。第 $i$ 台除雪车的描述包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i < b_i \le n$),表示分配给第 $i$ 台除雪车的道路片段的起点和终点。你可以假设 $a_i < a_{i+1}$,即除雪车是按照其负责片段的起点进行排序的。此外,没有任何一个片段完全包含在另一个片段中。

输出格式

你的程序应按除雪顺序输出除雪车的编号。输出应包含 $m$ 行,每行包含一个整数。

样例

输入 1

15 4
1 6
3 7
6 11
10 14

输出 1

2
1
3
4

说明

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.