QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 1024 MB Total points: 100

#1817. Permutación AND

Statistics

Se te da una secuencia de $n$ enteros no negativos distintos $a_1, a_2, \dots, a_n$.

Para la secuencia dada, se garantiza que para todos los números no negativos $x$, si existe algún $i$ tal que $a_i \ \& \ x = x$, entonces existe un $j$ tal que $a_j = x$. Aquí, $\&$ se refiere al operador AND a nivel de bits.

Encuentra una permutación $b_1, b_2, \dots, b_n$ de $a_1, a_2, \dots, a_n$ tal que $b_i \ \& \ a_i = 0$ para todo $i$. Si existen múltiples soluciones, encuentra cualquiera de ellas. Se garantiza que siempre existe una solución.

Entrada

La primera línea de la entrada contiene un entero $n$ ($1 \le n < 2^{18}$), que es la cantidad de enteros en la permutación.

Cada una de las siguientes $n$ líneas contiene un entero $a_i$ ($0 \le a_i < 2^{60}$), que representa la secuencia de entrada, en orden de $i$.

Todos los $a_i$ están garantizados de ser distintos. Para todos los números no negativos $x$, si existe algún $i$ tal que $a_i \ \& \ x = x$, entonces existe un $j$ tal que $a_j = x$.

Salida

Imprime $n$ líneas, cada una conteniendo un solo entero, que corresponden a los $b_i$, en orden de $i$.

Ejemplos

Entrada 1

6
0
1
4
5
2
6

Salida 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.