100 atcoder#ABC126F. [ABC126F] XOR Matching
[ABC126F] XOR Matching
Score : points
Problem Statement
Construct a sequence = {} of length that satisfies the following conditions, if such a sequence exists.
- Each integer between and (inclusive) occurs twice in .
- For any and such that , the formula holds.
What is xor (bitwise exclusive or)?
The xor of integers is defined as follows:
- When is written in base two, the digit in the 's place () is if the number of integers among whose binary representations have in the 's place is odd, and if that count is even.
For example, . (If we write it in base two: 011
101
110
.)
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there is no sequence that satisfies the condition, print -1
.
If there exists such a sequence , print the elements of one such sequence with spaces in between.
If there are multiple sequences that satisfies the condition, any of them will be accepted.
1 0
0 0 1 1
For this case, there are multiple sequences that satisfy the condition.
For example, when = {}, there are two pairs such that : and . Since and , this sequence satisfies the condition.
1 1
-1
No sequence satisfies the condition.
5 58
-1
No sequence satisfies the condition.