#P16013. [ICPC 2021 NAC] AND Permutation
[ICPC 2021 NAC] AND Permutation
题目描述
You are given a sequence of distinct nonnegative integers .
For the given sequence, it is guaranteed that for all nonnegative numbers , if there is some such that , then there is a such that . Here, refers to the bitwise AND operator.
Find a permutation of such that for all . If there are multiple solutions, find any such permutation. It is guaranteed that a solution always exists.
输入格式
The first line of input contains an integer (), which is the number of integers in the permutation.
Each of the next lines contains an integer (), which is the input sequence, in order of . All of the 's are guaranteed to be distinct. For all nonnegative numbers , if there is some such that , then there is a such that .
输出格式
Output lines, each containing a single integer, which are the 's, in order of .
6
0
1
4
5
2
6
4
6
0
2
5
1