CF925C.Big Secret

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vitya has learned that the answer for The Ultimate Question of Life, the Universe, and Everything is not the integer 54 42, but an increasing integer sequence a1,,ana_1, \ldots, a_n . In order to not reveal the secret earlier than needed, Vitya encrypted the answer and obtained the sequence b1,,bnb_1, \ldots, b_n using the following rules:

  • b1=a1b_1 = a_1 ;
  • bi=aiai1b_i = a_i \oplus a_{i - 1} for all ii from 2 to nn , where xyx \oplus y is the bitwise XOR of xx and yy .

It is easy to see that the original sequence can be obtained using the rule ai=b1bia_i = b_1 \oplus \ldots \oplus b_i .

However, some time later Vitya discovered that the integers bib_i in the cypher got shuffled, and it can happen that when decrypted using the rule mentioned above, it can produce a sequence that is not increasing. In order to save his reputation in the scientific community, Vasya decided to find some permutation of integers bib_i so that the sequence ai=b1bia_i = b_1 \oplus \ldots \oplus b_i is strictly increasing. Help him find such a permutation or determine that it is impossible.

输入格式

The first line contains a single integer nn ( 1n1051 \leq n \leq 10^5 ).

The second line contains nn integers b1,,bnb_1, \ldots, b_n ( 1bi<2601 \leq b_i < 2^{60} ).

输出格式

If there are no valid permutations, print a single line containing "No".

Otherwise in the first line print the word "Yes", and in the second line print integers b1,,bnb'_1, \ldots, b'_n — a valid permutation of integers bib_i . The unordered multisets {b1,,bn}\{b_1, \ldots, b_n\} and {b1,,bn}\{b'_1, \ldots, b'_n\} should be equal, i. e. for each integer xx the number of occurrences of xx in the first multiset should be equal to the number of occurrences of xx in the second multiset. Apart from this, the sequence ai=b1bia_i = b'_1 \oplus \ldots \oplus b'_i should be strictly increasing.

If there are multiple answers, print any of them.

输入输出样例

  • 输入#1

    3
    1 2 3
    

    输出#1

    No
    
  • 输入#2

    6
    4 7 7 12 31 61
    

    输出#2

    Yes
    4 12 7 31 7 61 
    

说明/提示

In the first example no permutation is valid.

In the second example the given answer lead to the sequence a1=4a_1 = 4 , a2=8a_2 = 8 , a3=15a_3 = 15 , a4=16a_4 = 16 , a5=23a_5 = 23 , a6=42a_6 = 42 .

首页