51 atcoder#ARC138D. [ARC138D] Differ by K bits
[ARC138D] Differ by K bits
Score : points
Problem Statement
You are given integers and . Determine whether there exists a permutation of satisfying the condition below, and construct one such sequence if it exists. Note that is -indexed.
- For every (), and differ by exactly bits in binary representation. The comparison is made after zero-padding both integers to bits.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there is no satisfying the condition, print No
.
If there is such a , print it in the following format:
Yes
If there are multiple solutions satisfying the condition, printing any of them will be accepted.
3 1
Yes
0 1 3 2 6 7 5 4
Here, we have in binary representation.
We can see that and , for example, differ by exactly bit, satisfying the condition for . The same goes for every .
2 2
No