QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 1024 MB 總分: 100

#1817. AND 排列

统计

給定一個包含 $n$ 個相異非負整數的序列 $a_1, a_2, \dots, a_n$。

對於給定的序列,保證對於所有非負整數 $x$,若存在某個 $i$ 使得 $a_i \ \& \ x = x$,則必存在某個 $j$ 使得 $a_j = x$。其中,$\&$ 代表位元運算 AND。

請找出 $a_1, a_2, \dots, a_n$ 的一個排列 $b_1, b_2, \dots, b_n$,使得對於所有 $i$,皆滿足 $b_i \ \& \ a_i = 0$。若存在多種解,輸出其中任意一種即可。題目保證解一定存在。

輸入格式

第一行包含一個整數 $n$ ($1 \le n < 2^{18}$),代表排列中整數的個數。

接下來 $n$ 行,每行包含一個整數 $a_i$ ($0 \le a_i < 2^{60}$),依序代表輸入序列的元素。所有 $a_i$ 保證相異。對於所有非負整數 $x$,若存在某個 $i$ 使得 $a_i \ \& \ x = x$,則必存在某個 $j$ 使得 $a_j = x$。

輸出格式

輸出 $n$ 行,每行包含一個整數,依序代表 $b_i$ 的值。

範例

輸入 1

6
0
1
4
5
2
6

輸出 1

4
6
0
2
5
1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#619Editorial Open集训队作业 解题报告 by 洪泽Qingyu2026-01-02 23:13:32 Download
#597Editorial Open集训队作业 解题报告 by 陈翔乐Qingyu2026-01-02 22:49:26 Download

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.