QOJ.ac

QOJ

実行時間制限: 5 s メモリ制限: 1024 MB 満点: 100

#1817. Hoán vị AND

統計

Bạn được cho một dãy gồm $n$ số nguyên không âm phân biệt $a_1, a_2, \dots, a_n$.

Đối với dãy đã cho, đảm bảo rằng với mọi số không âm $x$, nếu tồn tại một chỉ số $i$ sao cho $a_i \ \& \ x = x$, thì tồn tại một chỉ số $j$ sao cho $a_j = x$. Ở đây, $\&$ là toán tử AND bitwise.

Hãy tìm một hoán vị $b_1, b_2, \dots, b_n$ của $a_1, a_2, \dots, a_n$ sao cho $b_i \ \& \ a_i = 0$ với mọi $i$. Nếu có nhiều lời giải, hãy tìm bất kỳ hoán vị nào như vậy. Đảm bảo rằng luôn tồn tại một lời giải.

Dữ liệu vào

Dòng đầu tiên của dữ liệu vào chứa một số nguyên $n$ ($1 \le n < 2^{18}$), là số lượng các số nguyên trong hoán vị.

Mỗi dòng trong $n$ dòng tiếp theo chứa một số nguyên $a_i$ ($0 \le a_i < 2^{60}$), là dãy số đầu vào theo thứ tự của $i$. Tất cả các $a_i$ được đảm bảo là phân biệt. Với mọi số không âm $x$, nếu tồn tại một chỉ số $i$ sao cho $a_i \ \& \ x = x$, thì tồn tại một chỉ số $j$ sao cho $a_j = x$.

Dữ liệu ra

In ra $n$ dòng, mỗi dòng chứa một số nguyên duy nhất, là các giá trị $b_i$ theo thứ tự của $i$.

Ví dụ

Dữ liệu vào 1

6
0
1
4
5
2
6

Dữ liệu ra 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.