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,…,an . In order to not reveal the secret earlier than needed, Vitya encrypted the answer and obtained the sequence b1,…,bn using the following rules:
- b1=a1 ;
- bi=ai⊕ai−1 for all i from 2 to n , where x⊕y is the bitwise XOR of x and y .
It is easy to see that the original sequence can be obtained using the rule ai=b1⊕…⊕bi .
However, some time later Vitya discovered that the integers bi 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 bi so that the sequence ai=b1⊕…⊕bi is strictly increasing. Help him find such a permutation or determine that it is impossible.
输入格式
The first line contains a single integer n ( 1≤n≤105 ).
The second line contains n integers b1,…,bn ( 1≤bi<260 ).
输出格式
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′,…,bn′ — a valid permutation of integers bi . The unordered multisets {b1,…,bn} and {b1′,…,bn′} should be equal, i. e. for each integer x the number of occurrences of x in the first multiset should be equal to the number of occurrences of x in the second multiset. Apart from this, the sequence ai=b1′⊕…⊕bi′ 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=4 , a2=8 , a3=15 , a4=16 , a5=23 , a6=42 .