| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 121 | 81 | 68 | 70.103% |
A list of $N$ integers $a_1, \dots , a_N$ is stored in the memory of an electronic device. This device has a very peculiar operation available: bit swapping between numbers. More precisely, given integers $i,ドル $j$ and $k,ドル this operation swaps the $k$-th bit of the integer $a_i$ with the $k$-th bit of the integer $a_j$ (and vice-versa).
Very interesting phenomena can occur when performing this operation one or more times, such as obtaining numbers that did not even belong to the original list, or even numbers larger or smaller than all the original elements.
For this problem, we are interested in using the operation as many times as necessary to change the list of numbers so that the resulting list is the lexicographically maximum, that is, that $a_1$ is the largest possible, that $a_2$ is the largest possible among the possible solutions that maximize $a_1,ドル and so on.
The first line of input contains an integer $N$ (1ドル ≤ N ≤ 10^5$) and the second line contains $N$ integers, separated by spaces, corresponding to the list $a_1, \dots , a_N$ (0ドル ≤ a_i ≤ 10^9$).
Your program should print a single line containing $N$ space-separated integers corresponding to the lexicographically maximum obtainable sequence.
4 8 4 2 1
15 0 0 0
4 12 15 1 20
31 13 4 0