atcoder#AGC035A. [AGC035A] XOR Circle
[AGC035A] XOR Circle
Score : points
Problem Statement
Snuke has hats. The -th hat has an integer written on it.
There are camels standing in a circle. Snuke will put one of his hats on each of these camels.
If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes
; otherwise, print No
.
- The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.
What is XOR?
$$x_1 \oplus x_2 \oplus \ldots \oplus x_n$$$$n$$$$x_1, x_2, \ldots, x_n$$$$x_1 \oplus x_2 \oplus \ldots \oplus x_n$$$$2^k$$$$k \geq 0$$$$1$$$$x_1, x_2, \ldots, x_n$$$$1$$$$2^k$$$$0$$$$3 \oplus 5 = 6 $$Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 2 3
Yes
- If we put the hats with , , and in this order, clockwise, the condition will be satisfied for every camel, so the answer is
Yes
.
4
1 2 4 8
No
- There is no such way to distribute the hats; the answer is
No
.