QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#3017. 丢失的侏儒

Statistiques

$n$ 个侏儒喜欢排成一队拍集体照。每个侏儒都可以通过帽子上写着的 $1 \dots n$ 的唯一编号来识别。

假设有 $5$ 个侏儒,他们排队的顺序可能是:$1, 3, 4, 2, 5$。

现在,一位邪恶的魔术师会从队列中移除一些侏儒,并抹去你对侏儒原始顺序的记忆。剩下的结果是一个子序列,例如:$1, 4, 2$。

魔术师告诉你,如果你将 $1 \dots n$ 的所有排列按字典序排序,那么原始的侏儒序列就是其中第一个包含该剩余子序列的排列。你的任务是找出这个原始的侏儒序列。

输入格式

每个输入包含一个测试用例。注意,你的程序可能会在不同的输入上运行多次。每个测试用例的第一行包含两个整数 $n$ 和 $m$ ($1 \le m \le n \le 10^5$),其中 $n$ 是原始侏儒的数量,$m$ 是魔术师施法后剩余侏儒的数量。接下来的 $m$ 行,每行包含一个整数 $g$ ($1 \le g \le n$)。这些是按顺序剩余的侏儒编号。保证 $g$ 的值互不相同。

输出格式

输出 $n$ 行,每行包含一个整数,表示包含剩余侏儒子序列的字典序最小的排列。

样例

样例输入 1

5 3
1
4
2

样例输出 1

1
3
4
2
5

样例输入 2

7 4
6
4
2
1

样例输出 2

3
5
6
4
2
1
7

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.