QOJ.ac

QOJ

时间限制: 5 s 内存限制: 1024 MB 总分: 100

#1817. AND Permutation

统计

$n$ 個の相異なる非負整数からなる数列 $a_1, a_2, \dots, a_n$ が与えられます。 この数列について、任意の非負整数 $x$ に対して、ある $i$ が存在して $a_i \& x = x$ となるならば、ある $j$ が存在して $a_j = x$ となることが保証されています。ここで、$\&$ はビットごとの AND 演算子を表します。

すべての $i$ について $b_i \& a_i = 0$ を満たすような、$a_1, a_2, \dots, a_n$ の置換 $b_1, b_2, \dots, b_n$ を求めてください。複数の解が存在する場合は、そのうちのいずれかを出力してください。解は必ず存在することが保証されています。

入力

入力の最初の行には、置換に含まれる整数の個数を表す整数 $n$ ($1 \le n < 2^{18}$) が含まれます。 続く $n$ 行の各行には、入力数列の $i$ 番目の要素を表す整数 $a_i$ ($0 \le a_i < 2^{60}$) が含まれます。 すべての $a_i$ は相異なることが保証されています。また、任意の非負整数 $x$ に対して、ある $i$ が存在して $a_i \& x = x$ となるならば、ある $j$ が存在して $a_j = x$ となることが保証されています。

出力

$n$ 行にわたって、$i$ 番目の順に $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.