QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#50. Zalmoxis

Estadísticas

Tanaka 对达契亚神话产生了兴趣(达契亚人是罗马人之前居住在罗马尼亚地区的人民)。在这个神话中,Zalmoxis 是至高神,而 Pleistoros 是战神。在 Tanaka 对这个神话的新解读中,Zalmoxis 有一种强大的新攻击方式,称为 ZalPunch,并且他钟爱 ZalSequence。

ZalPunch 是一种可以应用于非负整数序列的攻击。它由从序列中取出一个严格正整数 $x$,并将其替换为两个 $x - 1$ 组成。例如:

  • $[1] \xrightarrow{ZalPunch} [0, 0]$
  • $[1, 23, 3] \xrightarrow{ZalPunch} [1, 22, 22, 3]$
  • 但 $[1, 3] \xrightarrow{ZalPunch} [2, 1, 2]$ 是错误的,因为序列的顺序很重要。

ZalSequence(Zalmoxis 钟爱的序列)是以下序列之一:

  • 序列 $[30]$。
  • 可以通过对另一个 ZalSequence 应用一次 ZalPunch 得到的序列。

例如,$[30]$、$[29, 29]$ 和 $[29, 28, 27, 27]$ 是 ZalSequence,但 $[28, 29, 28]$ 不是。

起初,Zalmoxis 创建了一个长度为 $N + K$ 的 ZalSequence。然而,他的一个敌人摧毁了这个序列中的 $K$ 个值,留下了 $N$ 个剩余的值。称这个序列为 $S$。给定 $N$、$K$ 和 $S$,在 $S$ 中插入 $K$ 个值以创建一个长度为 $N + K$ 的 ZalSequence。保证在所有测试用例中这都是可能的。

输入格式

第一行包含正整数 $N$ 和 $K$。 下一行包含 $N$ 个非负整数,即序列 $S$ 的值。

输出格式

第一行且仅一行,包含一个长度为 $N + K$ 的非负整数序列,它既是一个 ZalSequence,又包含 $S$ 作为其子序列(即 $S$ 的元素以可能不连续的位置出现在输出中)。

数据范围

  • $1 \le N \le 1\,000\,000$
  • $1 \le K \le 1\,000\,000$
  • $1 \le N + K \le 1\,000\,000$
  • 输入中的序列是长度为 $N + K$ 的 ZalSequence 的子序列。

子任务

  • 所有测试用例均不分组。
  • 子任务 1(30 分):$K = 1$
  • 子任务 2(70 分):无额外限制

样例

样例输入 1

5 1
29 27 25 25 28

样例输出 1

29 27 25 25 26 28

样例输入 2

1 5
29

样例输出 2

29 28 27 26 25 25

说明

在第一个样例中,$[29, 27, 25, 25, 26, 28]$ 可以通过以下 ZalPunch 操作从 $[30]$ 得到: $[30] \to [29, 29] \to [29, 28, 28] \to [29, 27, 27, 28] \to [29, 27, 26, 26, 28] \to [29, 27, 25, 25, 26, 28]$

在第二个样例中,$[29, 28, 27, 26, 25, 25]$ 可以通过以下 ZalPunch 操作从 $[30]$ 得到: $[30] \to [29, 29] \to [29, 28, 28] \to [29, 28, 27, 27] \to [29, 28, 27, 26, 26] \to [29, 28, 27, 26, 25, 25]$

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.