QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100 تواصل

#2351. 迷失在传输中

الإحصائيات

Dima 有一个包含 $n$ 个数字的集合。Dima 想要将这个集合传输给 Katya。他将集合中的数字一个接一个地取出,以他喜欢的任意顺序输入到发射器中。

Katya 按照 Dima 输入的顺序从接收器接收数字。然而,传输通道并不理想,因此其中一个数字可能在传输过程中丢失。尽管如此,对于 Katya 来说,准确重构出 Dima 想要传输的集合非常重要。

请帮助 Dima 和 Katya 事先约定好他们如何传输数字,以便 Katya 总是能够重构出 Dima 的集合,即使其中一个元素在传输过程中丢失了。

交互

在本题中,你的程序将在每个测试点上运行两次。每个测试点包含多个独立的测试用例。输入和输出中,同一行相邻的数字均以空格分隔。

在第一次运行中,你的程序作为 Dima 传输集合。第一行包含单词 “transmit”。第二行包含一个整数 $t$,表示测试用例的数量 ($1 \le t \le 1000$)。接下来的 $t$ 行,每行描述一个测试用例。该行以一个整数 $n$ 开头,表示集合中元素的数量 ($20 \le n \le 100$)。随后是 $n$ 个两两不同的整数 $a_1, a_2, \dots, a_n$,即集合中的元素 ($1 \le a_i \le 500$)。

你需要输出 $t$ 行,每行对应一个测试用例。在每一行中,输出相应的整数 $a_1, a_2, \dots, a_n$,每个数字恰好出现一次,顺序不限。

在第二次运行中,你的程序作为 Katya 重构集合。第一行包含单词 “recover”。第二行包含一个整数 $t$,表示测试用例的数量,与第一次运行相同 ($1 \le t \le 1000$)。接下来的 $t$ 行,每行描述一个测试用例。该行以一个整数 $m$ 开头,表示 Katya 接收到的整数数量 ($19 \le m \le 100$)。随后是 $m$ 个两两不同的整数 $b_1, b_2, \dots, b_m$,即 Katya 实际接收到的整数。这些是 Dima 在第一次运行中发送的整数,按传输顺序给出。然而,其中一个整数可能被省略了(此时 $m$ 比第一次运行中对应的 $n$ 小 1)。

你需要输出 $t$ 行,每行对应一个测试用例。在每一行中,输出相应测试用例中的整数 $a_1, a_2, \dots, a_n$,每个数字恰好出现一次,顺序不限。

说明

在本题中,测试数据使用伪随机数生成器生成。在每个测试点中,测试用例的数量 $t$ 和每个测试用例中集合的大小 $n$ 都是预先选定的。之后,每个大小为 $n$ 的集合都是从所有由 1 到 500 之间的整数组成的集合中等概率随机选取的。集合中的元素以随机顺序给出。

此外,在每个测试用例中,预先决定了哪个数字会在传输中丢失。对于大小为 $n$ 的集合,从 $1$ 到 $n+1$ 的所有整数中等概率随机选择一个位置 $p$。如果 $p \le n$,则意味着第 $p$ 个打印的数字会丢失。当 $p = n+1$ 时,所有数字都将成功传输。

样例

输入 1

transmit
2
20 97 388 459 467 32 99 98 296 403 325 330 271 87 333 378 267 405 58 426 374
20 125 481 451 150 495 136 444 192 118 26 68 281 120 61 494 339 86 292 100 32

输出 1

405 97 87 58 374 98 271 296 330 267 99 32 378 333 325 467 388 403 459 426
494 68 481 61 120 125 281 444 150 86 339 26 32 118 451 136 495 100 292 192

输入 2

recover
2
19 97 87 58 374 98 271 296 330 267 99 32 378 333 325 467 388 403 459 426
20 494 68 481 61 120 125 281 444 150 86 339 26 32 118 451 136 495 100 292 192

输出 2

97 87 58 374 98 271 296 330 267 99 32 378 333 325 467 388 403 459 426 405
494 68 481 61 120 125 281 444 150 86 339 26 32 118 451 136 495 100 292 192

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.