Logo
(追記) (追記ここまで)

22922번 - AND Permutation 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB (추가 메모리 없음)135474437.931%

문제

You are given a sequence of $n$ distinct nonnegative integers $a_1, a_2, \ldots, a_n$.

For the given sequence, it is guaranteed that for all nonnegative numbers $x,ドル if there is some $i$ such that $a_i \ \&\ x = x,ドル then there is a $j$ such that $a_j = x$. Here, $\&$ refers to the bitwise AND operator.

Find a permutation $b_1, b_2, \ldots, b_n$ of $a_1, a_2, \ldots, a_n$ such that $b_i \ \&\ a_i = 0$ for all $i$. 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 $n$ (1ドル \le n < 2^{18}$), which is the number of integers in the permutation.

Each of the next $n$ lines contains an integer $a_i$ (0ドル \le a_i < 2^{60}$), which is the input sequence, in order of $i$. All of the $a_i$'s are guaranteed to be distinct. For all nonnegative numbers $x,ドル if there is some $i$ such that $a_i \ \&\ x = x,ドル then there is a $j$ such that $a_j = x$.

출력

Output $n$ lines, each containing a single integer, which are the $b_i$'s, in order of $i$.

제한

예제 입력 1

6
0
1
4
5
2
6

예제 출력 1

4
6
0
2
5
1

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2021 A번

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 2: The American Contest A번

  • 문제를 만든 사람: Lewin Gan
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /