QOJ.ac

QOJ

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

#4825. 奇偶组合

الإحصائيات

称 $n$ 的一个 $k$-组合为 $n$ 元集合 $\{1, 2, \dots, n\}$ 的一个 $k$ 元子集。为了表示一个组合,将其元素按升序排列。例如,3 的 2-组合如下:$\{1, 2\}, \{1, 3\}, \{2, 3\}$。

若一个组合的元素个数为偶数,则称该组合为偶组合;否则称为奇组合。对于固定的 $n > 0$,考虑两个集合:$A_n$ 为 $n$ 的所有偶组合构成的集合,$B_n$ 为 $n$ 的所有奇组合构成的集合。可以证明 $A_n$ 和 $B_n$ 包含相同数量的组合。

对于每个 $n = 1, 2, \dots, 50$,你的任务如下:构造一个集合 $A_n$ 和 $B_n$ 之间的双射(一一对应)。之后,给定这些集合中的一个元素,输出另一个集合中对应的元素。

交互

为了验证你确实构造了一个双射,在本题中,你的程序将在每组测试数据上运行两次。每一行输入均以换行符结束。

第一次运行

在第一次运行中,第一行包含一个整数 $t$,表示测试用例的数量($1 \le t \le 1000$)。随后是各测试用例的描述。

每个测试用例表示一个组合,由两行输入给出。第一行包含两个空格分隔的整数 $n$ 和 $k$($1 \le n \le 50, 0 \le k \le n$)。第二行包含 $k$ 个空格分隔的整数 $a_1, a_2, \dots, a_k$,即该组合的元素($1 \le a_1 < a_2 < \dots < a_k \le n$)。若 $k = 0$,则第二行为空。

对于每个测试用例,输出另一个集合中对应的组合。组合的输出格式与输入格式完全相同。输出的组合必须与给定的组合具有相同的 $n$,且 $k$ 的奇偶性必须不同。对应关系没有其他限制。

第二次运行

在第二次运行中,输入格式与第一次运行完全相同。然而,在每个测试用例中,给定的组合不再是初始组合,而是第一次运行中输出的组合。

对于每个测试用例,与第一次运行一样,输出另一个集合中对应的组合。组合的输出格式与输入格式完全相同。由于该对应关系必须是一个双射,第二次运行中输出的组合必须与第一次运行中给定的组合相同。这是评测程序将要检查的内容。

样例

对于每个测试,第二次运行的输入取决于第一次运行中你的程序的输出。下面展示了某解法在第一组测试上的两次运行。

样例 1

输入(第一次运行):

6
3 0
2 1
1
3 3
1 2 3
3 1
1
3 1
2
3 1
3

输出(第一次运行):

3 3
1 2 3
2 2
1 2
3 0
3 2
2 3
3 2
1 3
3 2
1 2

样例 2

输入(第二次运行):

6
3 3
1 2 3
2 2
1 2
3 0
3 2
2 3
3 2
1 3
3 2
1 2

输出(第二次运行):

3 0
2 1
1
3 3
1 2 3
3 1
1
3 1
2
3 1
3

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.