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

32443번 - Lecographically Maximum 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB121816870.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.

제한

예제 입력 1

4
8 4 2 1

예제 출력 1

15 0 0 0

예제 입력 2

4
12 15 1 20

예제 출력 2

31 13 4 0

힌트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona de Programação da SBC 2024 L번

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

출처

대학교 대회

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

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