QOJ.ac

QOJ

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

#536. 社团成员

الإحصائيات

Byteotian 讨论俱乐部在各个方面都非常非同寻常。其 $2^n$ 名成员每人都填写了一份包含 $n$ 个基本“是”或“否”问题的问卷。每位成员的回答当然可以编码为一个 $n$ 位的二进制序列,这对应于 $0$ 到 $2^n - 1$ 之间的一个整数。我们忽略具体的问题表述或“是”与“否”到 $0$ 和 $1$ 的映射。相反,我们列出关于俱乐部成员的一些非同寻常的事实如下。

没有两名俱乐部成员给出了相同的回答,即上述范围内的每个数字都出现过。此外,俱乐部成员中恰好有 $2^{n-1}$ 名男性,其余 $2^{n-1}$ 名成员为女性。如果这还不够非同寻常的话,他们实际上组成了 $2^{n-1}$ 对夫妻。在俱乐部会议期间,成员们围坐在一张圆桌旁。我们希望安排他们的座位,使得每位成员都坐在其伴侣和一名“几乎一致”的成员之间,即仅有一道问题回答不同的成员。

输入格式

标准输入的第一行包含一个整数 $n$,表示基本问题的数量。 接下来的 $2^{n-1}$ 行描述了成员夫妻:第 $i$ 行包含两个整数 $a_i, b_i$ ($0 \le a_i, b_i \le 2^n - 1$),由空格分隔,表示问卷回答编码为 $a_i$ 和 $b_i$ 的俱乐部成员是一对夫妻。代表回答的 $2^n$ 个数字中的每一个都会在输入中恰好出现一次。

输出格式

输出一行到标准输出,如果不存在满足上述要求的座位安排,则输出单词 NIE(波兰语中的“不”);否则,输出一个有效的座位安排,即一个包含 $2^n$ 个整数的序列(按圆桌顺序排列的成员回答编码),由空格分隔。

如果存在多个正确答案,输出其中任意一个即可。

样例

输入格式 1

3
0 5
4 1
3 6
7 2

输出格式 1

0 5 7 2 6 3 1 4

样例评分测试

1ocen: $n = 4$,对于所有偶数 $i$,成员 $i$ 和 $i+1$ 组成一对夫妻; 2ocen: $n = 10$,对于所有奇数 $i$($i = 2^n - 1$ 除外),成员 $i$ 和 $i+1$ 组成一对夫妻,而 $i = 2^n - 1$ 与成员 $0$ 组成一对; 3ocen: $n = 15$,随机测试,输入中的夫妻对按 $a_i$ 的升序给出。

子任务

所有测试用例被分为 18 个子任务,每个子任务分值为 5 或 6 分。第 $k$ 个子任务 ($1 \le k \le 18$) 中的所有测试用例满足 $n = k + 1$(因此 $2 \le n \le 19$)。

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.