QOJ.ac

QOJ

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

#1817. Permutacja AND

統計

Dany jest ciąg $n$ różnych nieujemnych liczb całkowitych $a_1, a_2, \dots, a_n$.

Dla danego ciągu zagwarantowano, że dla każdej nieujemnej liczby $x$, jeśli istnieje takie $i$, że $a_i \ \& \ x = x$, to istnieje takie $j$, że $a_j = x$. Tutaj $\&$ oznacza bitowy operator AND.

Znajdź permutację $b_1, b_2, \dots, b_n$ ciągu $a_1, a_2, \dots, a_n$ taką, że $b_i \ \& \ a_i = 0$ dla wszystkich $i$. Jeśli istnieje wiele rozwiązań, znajdź dowolne z nich. Zagwarantowano, że rozwiązanie zawsze istnieje.

Wejście

W pierwszej linii wejścia znajduje się liczba całkowita $n$ ($1 \le n < 2^{18}$), będąca liczbą liczb całkowitych w permutacji.

Każda z kolejnych $n$ linii zawiera liczbę całkowitą $a_i$ ($0 \le a_i < 2^{60}$), będącą elementem ciągu wejściowego, w kolejności indeksów $i$.

Wszystkie liczby $a_i$ są parami różne. Dla każdej nieujemnej liczby $x$, jeśli istnieje takie $i$, że $a_i \ \& \ x = x$, to istnieje takie $j$, że $a_j = x$.

Wyjście

Wypisz $n$ linii, z których każda zawiera pojedynczą liczbę całkowitą, będącą elementem $b_i$, w kolejności indeksów $i$.

Przykład

Wejście 1

6
0
1
4
5
2
6

Wyjście 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.