atcoder#AGC031C. [AGC031C] Differ by 1 Bit
[AGC031C] Differ by 1 Bit
Score : points
Problem Statement
You are given integers and . Determine if there exists a permutation of that satisfies all of the following conditions, and create one such permutation if it exists.
- For all , the binary representations of and differ by exactly one bit.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there is no permutation that satisfies the conditions, print NO
.
If there is such a permutation, print YES
in the first line.
Then, print in the second line, with spaces in between.
If there are multiple solutions, any of them is accepted.
2 1 3
YES
1 0 2 3
The binary representation of is , where any two adjacent elements differ by exactly one bit.
3 2 1
NO