Problem:


Score : 300 points

Problem Statement

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N 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?

The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.

For example, 3 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

If we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.

Sample Input 2

4
1 2 4 8

Sample Output 2

No

There is no such way to distribute the hats; the answer is No.



Sample input:
3
1 2 3


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

for i in range(n):
    if a[i] != a[(i+3)%n]:
        print('No')
        exit()

if a[0]!=a[1]^a[2] or a[1]!=a[0]^a[2] or a[2]!=a[0]^a[1]:
    print('No')
    exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

for i in range(n):
    if a[i] != a[(i+3)%n]:
        print('No')
        exit()

if a[0]!=a[1]^a[2] or a[1]!=a[0]^a[1] or a[2]!=a[0]^a[1]:
    print('No')
    exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

if n==3:
    print('Yes')
    exit()

for i in range(n):
    if a[i] != a[(i+3)%n]:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
l = sorted(list(map(int,input().split())))
for i in range(n-2):
  a,b,c = l[i:3+i]
  if a^c ==b:
    continue
  else:
    print("No")
    exit()
else:
  if l[-2]^l[0]==l[-1] and l[-1]^l[1]==l[0]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))

from collections import Counter

c=Counter(A)

if len(c)!=3:
    print("No")
    exit()

n=list(c.keys())


if n[0]|n[1]==n[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
A.sort()

ans='Yes'
i=0
while i<N:
    if A[(i-1)%N]^A[(i+1)%N]!=A[i]:
        ans='No'
    i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())

ans='Yes'
i=0
while i<N:
    if A[(i-1)%N]^A[(i+1)%N]!=A[i]:
        ans='No'
    i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
di = {}
for i in a:
    if i in di:
        di[i] += 1
    else:
        di[i] = 1
exit()
k = list(di.keys())
v = list(di.values())
if n%3!=0 and len(di)>1:
    print('No')
elif len(di)==3 and v[0]==v[1]==v[2] and k[0]^k[1]^k[2]==0:
    print('Yes')
elif len(di)==2 and (v[0]<v[1] and v[0]==n//3 and k[0]==0) or (v[0]>v[1] and v[1]==n//3 and k[1]==0):
    print('Yes')
elif len(di)==1 and k[0]==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if not n % 3 == 0:
    if a[n - 1] == 0:
        print("Yes")
    else:
        print("No")
else:
    x, y, z = a.count(a[0]), a.count(a[n // 3]), a.count(a[2 * (n // 3)])
    if x == y == z == n // 3:
        if a[0] ^ a[n // 3] ^ a[2 * (n // 3)] == 0:
            print("Yes")
        else:
            print("No")
    elif a[0] == 0 and x == n // 3 and y == z == 2 * (n // 3):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if not n % 3 == 0:
    if a[n - 1] == 0:
        print("Yes")
    else:
        print("No")
else:
    x, y, z = a.count(a[0]), a.count(a[n // 3]), a.count(a[2 * (n // 3)])
    if x == y == z == n // 3:
        print("Yes")
    elif a[0] == 0 and x == n // 3 and y == z == 2 * (n // 3):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if not n % 3 == 0:
    if a[n - 1] == 0:
        print("Yes")
    else:
        print("No")
else:
    x, y, z = a.count(a[0]), a.count(a[n // 3]), a.count(a[2 * (n // 3)])
    if x == y == z == n // 3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

if (a[1] ^ a[-1]) != a[0]:
    
    for i in range(1,n-2):
        if (a[i-1] ^ a[i+1]) != a[i]:
            continue
        
        else:
            print('Yes')
            exit()
    
    
    if (a[0] ^ a[-2]) != a[-1]:
        print('No')
        exit()
    
    else:
        print('Yes')
        exit()

else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

if (a[1] ^ a[-1]) == a[0]:
    
    for i in range(1,n-2):
        if (a[i-1] ^ a[i+1]) == a[i]:
            continue
        
        else:
            print('No')
            exit()
    
    
    if (a[0] ^ a[-2]) == a[-1]:
        print('Yes')
        exit()
    
    else:
        print('No')
        exit()

else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = (int)(input())
a = list(map(int, input().split(" ")))
#print(a)
if n % 3 != 0:
  print("No")
else:
  print("Yes" if a.count(a[0]) == a.count(a[1]) == a.count(a[2]) else "No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
# import math
N = int(input())
a = [int(x) for x in input().split()]
for i in range(N):
    ans = []
    ans.append(a[i])
    for k in range(1, N):
        ans.append(a[k])
        if ans[-2] ^ ans[-1] in a:
            ans.append(ans[-2] ^ ans[-1])
            print(ans[-2] ^ ans[-1], ans[-2], ans[-1])
            if len(ans) == N:
                print("Yes")
                sys.exit()
        else:
            break
print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
hats = [int(x) for x in input().split()]
hats.append(hats[0])
hats.append(hats[1])

ans = 'Yes'
for i in range(1, n + 1):
    if hats[i - 1] ^ hats[i + 1] != hats[i]:
        ans = 'No'
        break


print(ans)

Submission status: Wrong Answer

Solution code:
inNum = int(input())

intArr = []

for x in input().split(' '):
    intArr.append(int(x))
myBool = False
for x in range(len(intArr)-1):
    if(0== intArr.count(intArr[x]^intArr[x+1])):
        print("No")
        break
    elif(x == len(intArr)-2):
        print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = Counter(list(map(int, input().split())))
b = set(a.values())
if a[0] == N:
    print('Yes')
elif N % 3 == 0:
    if len(b) == 1:
        print('Yes')
    elif len(b) == 2:
        if a[0] == N // 3:
            if (N*2) // 3 in b:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
broke = False
if a[0] != a[N-1] ^ a[1]:
    broke = True
    print('No')
elif a[N-1] != a[0] ^ a[N-2]:
    broke = True
    print('No')
if broke == False:
    for i in range(1,N-1):
        if a[i] != a[i-1] ^ a[i+1]:
            broke = True
            print('No')
            break
if broke == False:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
x=[0]*3
x[0] = a.count(a[0])
x[1] = a.count(a[n//2])
x[2] = a.count(a[-1])
x.sort()

if a[0]^a[n//2] == a[-1] and x[0] == x[1] == x[2] == n//3:
    print('Yes')
elif x[0] == 0 and x[0] == n//3 and x[1] == x[2] == n*2//3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
x=[0]*3
x[0] = a.count(a[0])
x[1] = a.count(a[n//2])
x[2] = a.count(a[-1])
x.sort()

if x[0] == x[1] == x[2] == n//3 or (a[0] == 0 and x[0]==n//3 and x[1]==x[2]==2*n//3):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
    
if n%3==0 and a.count(a[0])%(n//3) == a.count(a[-1])%(n//3) == a.count(a[len(a)//2])%(n//3)==0:
    print("Yes")
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()

if n%3==0 and a.count(a[0])%(n//3) == a.count(a[-1])%(n//3) == a.count(a[len(a)//2])%(n//3)==0:
    print("Yes")
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()

if n%3==0 and a.count(a[0])%(n//3) == a.count(a[-1])%(n//3) == a.count(a[len(a)//2])%(n//3):
    print("Yes")
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()

if n%3==0 and a.count(a[0]) == a.count(a[-1]) == a.count(a[len(a)//2]) == n//3:
    print("Yes")
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter
def judge(vals):
    return vals[0] ^ vals[1] ^ vals[2] == 0
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = "No"
    c = Counter(A)
    if N % 3 == 0:
        if (len(c) == 2 and c[0] * 3 == N) or (len(c) == 3 and sum(c.values()) == N and judge(list(c.keys()))):
            ans = "Yes"
    else:
        if c[0] == N:
            ans = "Yes"
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = "No"
    c = Counter(A)
    if N % 3 == 0:
        if (len(c) == 2 and c[0] * 3 == N) or (len(c) == 3 and sum(c.values()) == N):
            ans = "Yes"
    else:
        if c[0] == N:
            ans = "Yes"
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 3 != 0:
    print('No')
else:
    s = list(set(a))
    if len(s) != 3:
        print('No')
    elif s[0] ^ s[1] == s[2]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(map(int,input().split()))
a.sort()
d = {}
for i in range(n):
    if(a[i] not in d):d[a[i]] = 1
    else:d[a[i]] += 1
if(len(d) == 1):
    if(a[0] == 0):
        print('Yes')
        exit()
elif(len(d)%3 == 0):
    if(len(d) == 2):
        if(0 in d):
            if(d[0] == n // 3):
                print('Yes')
                exit()
    elif(len(d) == 3):
        k = list(d.keys())
        if(k[0]^k[1]^k[2] == 0):
            if(d[k[0]] == n // 3 and d[k[1]] == n // 3 and d[k[2]] == n // 3):
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def judge(a, b, c):
    return a ^ b ^ c == 0
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = "Yes"
    for i in range(N):
        if i == 0:
            a, b, c = A[-1], A[0], A[1]
        elif i == N-1:
            a, b, c = A[i-1], A[i], A[0]
        else:
            a, b, c = A[i-1], A[i], A[i+1]
        if not judge(a, b, c):
            ans = "No"
            break
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ans='No'

if len(li)==3:
    if N%3 == 0:
        if li[0]== N//3 and li[1]==N//3:
            ans='Yes'           
elif len(li)==2:
    if N%3 == 0:
        if li[0]== 2*N//3 or li[1]==2*N//3:
            ans='Yes'
elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ans='No'

if len(li)==3:
    if N%3 == 0:
        if li[0]== N/3 and li[1]==N/3:
            ans='No'           
elif len(li)==2:
    if N%3 == 0:
        if li[0]== 2*N/3 or li[1]==2*N/3:
            ans='Yes'
elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ans='No'

if len(li)==3:
    if N%3 == 0:
        if li[0]== N/3 and li[1]==N/3:
            ans='Yes'           
elif len(li)==2:
    if N%3 == 0:
        if li[0]== 2*N/3 or li[1]==2*N/3:
            ans='Yes'
elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ans='No'

if len(li)==3:
    if N%3 == 0:
        if li[0]== N/3 and li[1]==N/3 and li[2]==N/3:
            ans='Yes'
elif len(li)==2:
    if N%3 == 0:
        if li[0]== 2*N/3 or li[1]==2*N/3:
            ans='Yes'

elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ans='No'

if len(li)==3:
    if N%3 == 0:
        if li[0]==li[1] and li[0]==li[2]:
            ans='Yes'
elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
if len(c) == 0 and c[0] > 0:
    print('Yes')
elif len(c) == 2 and c[0] == N//3:
    print('Yes')
elif len(c) == 3:
    x, y, z = c.keys()
    if x ^ y ^ z == 0 and all(n == N // 3 for n in c.values()):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
if len(c) == 2 and c[0] == N//3:
    print('Yes')
elif len(c) == 3:
    x, y, z = c.keys()
    if x ^ y ^ z == 0 and all(n == N // 3 for n in c.values()):
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations
N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
if len(c) == 2 and c[0] == N//3:
    print('Yes')
elif len(c) == 3:
    x, y, z = c.keys()
    if x ^ y ^ z == 0 and any(x==y==N//3 for x, y in combinations(c.values(), 2)):
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%3 !=0:
  print('No')
  exit()
A = list(map(int,input().split()))
from collections import Counter
A = list(Counter(A).most_common())

B = []
for a,c in A:
  if c != n//3:
    print('No')
    exit()
  B.append(a)
n = len(str(max(B)))
  
B = [[(1<<j&i)>>j for j in range(30)] for i in B]
for i in range(30):
  if B[0][i]^B[1][i]^B[2][i] != 0:
    print('No')
    break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(set(a)))
l=len(b)
if l>=4:
    print("No")
    exit()
else:
    if l==1:
        if b[0]==0:
            print("Yes")
        else:
            print("No")
    elif l==2:
        if n%3!=0:
            print("No")
        else:
            if b[0]!=0:
                print("No")
            else:
                cnt1=a.count(b[0])
                cnt2=a.count(b[1])
                if cnt2==(n//3)*2:
                    print("Yes")
                else:
                    print("No")
    else:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            cnt3=a.count(b[2])
            print(cnt1,cnt2,cnt3)
            if cnt1!=n//3 or cnt2!=n//3 or cnt3!=n//3:
                print("No")
            else:
                if b[0]^b[2]!=b[1]:
                    print("No")
                else:
                    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(set(a)))
l=len(b)
if l>=4:
    print("No")
    exit()
else:
    if l==1:
        if b[0]==0:
            print("Yes")
        else:
            print("No")
    elif l==2:
        if n%3!=0:
            print("No")
        else:
            if b[0]!=0:
                print("No")
            else:
                cnt1=a.count(b[0])
                cnt2=a.count(b[1])
                if cnt2==(n//3)*2:
                    print("Yes")
                else:
                    print("No")
    else:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            cnt3=a.count(b[2])
            if cnt1!=n//3 or cnt2!=n//3 or cnt3!=n//3:
                print("No")
            else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(set(a)))
l=len(b)
if l>=4:
    print("No")
    exit()
else:
    if l==1:
        if b[0]==0:
            print("Yes")
        else:
            print("No")
    elif l==2:
        if n%3!=0:
            print("No")
        else:
            if b[0]!=0:
                print("No")
            else:
                cnt1=a.count(b[0])
                cnt2=a.count(b[1])
                if cnt2==(n//3)*2:
                    print("Yes")
                else:
                    print("No")
    else:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            cnt3=a.count(b[2])
            if cnt1==n//3 and cnt2==n//3 and cnt3==n//3:
                print("Yes")
            else:
                print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(set(a)))
l=len(b)
if l>=4:
    print("No")
    exit()
else:
    if l==1:
        if b[0]==0:
            print("Yes")
        else:
            print("No")
    elif l==2:
        if n%3!=0:
            print("No")
        else:
            if b[0]!=0:
                print("No")
            else:
                cnt1=a.count(b[0])
                cnt2=a.count(b[1])
                if cnt2==(n//3)*2:
                    print("Yes")
                else:
                    print("No")
    else:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            cnt3=a.count(b[2])
            if cnt1==cnt2 and cnt2==cnt3:
                print("Yes")
            else:
                print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(set(a)))
l=len(b)
if l>=4:
    print("No")
    exit()
else:
    if l==1:
        if b[0]==0:
            print("Yes")
        else:
            print("No")
    elif l==2:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            if cnt1==(n//3)*2 or cnt2==(n//3)*2:
                print("Yes")
            else:
                print("No")
    else:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            cnt3=a.count(b[2])
            if cnt1==cnt2==cnt3:
                print("Yes")
            else:
                print("No")

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
a = [a[-1]] + a + [a[0]]
for bf, a, af in zip(a, a[1:], a[2:]):
    if bf ^ af != a:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  if b==0 and A.count(0)==(N//3)*2:
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c):
    if a^b==c:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  if b==0 and A.count(0)==(N//3)*2:
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c):
    if a^b==c and b^c==a and c^a==b:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  print(a,b)
  if b==0 and A.count(0)==(N//3)*2:
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c):
    if a^b==c and b^c==a and c^a==b:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  print(a,b)
  if b==0 and A.count(0)==(N//3)*2:
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c):
    if a^b==c:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  print(a,b)
  if b==0 and A.count(0)==(N//3)*2:
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c) and a^b==c:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

if N%3!=0:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
else:
  B=sorted(A)
  print(B)
  a=N//3
  if B[2*a-1]==0:
    print('Yes')
  else:
    if len(set(B))!=3:
      print('No')
    else:
      C=list(set(B))
      C=sorted(C)
      C1,C2,C3=C[0],C[1],C[2]
      if C1^C2^C3==0 and B==[C1]*a+[C2]*a+[C3]*a:
        print('Yes')
      else:
        print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

if N%3!=0:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
else:
  B=sorted(A)
  a=N//3
  if B[2*a-1]==0:
    print('Yes')
    exit()
  if B[a-1]^B[2*a-1]^B[3*a-1]==0 and len(set(B))==3 and B[0]^B[a]^B[2*a]==0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))

if N%3!=0:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
else:
  B=sorted(A)
  a=N//3
  if B[2*a-1]==0:
    print('Yes')
    exit()
  if B[a-1]^B[2*a-1]^B[3*a-1]==0 and len(set(B))==3:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
if N%3!=0:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
else:
  A.append(A[0])
  A.append(A[1])
  for i in range(N):
    d=A[i]^A[i+1]^A[i+2]
    if d!=0:
      print('No')
  print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
if N%3!=0:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
else:
  A.append(A[0])
  d=A[0]
  for i in range(N):
    d=d^A[i+1]
  if d==0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
if N%3!=0:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
else:
  A.append(A[0])
  A.append(A[1])
  for i in range(N):
    d=A[i]^A[i+1]^A[i+2]
    if d!=0:
      print('No')
      exit()
  print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input());l=list(map(int,input().split()))

from collections import Counter as co
var=co(l).items()

if n<=4:
    from itertools import permutations as pe
    for i in pe(l,r=None):
        #rは長さ、Noneでiteraterの長さ
        for i in range(n):
            if l[-1+i]^l[(i+1)%n]==l[i]:continue
            break
        else:print("Yes");exit()
    else:print("No");exit()
for i in l:
    hanten=~i&(pow(2,(len(bin(i))-2))-1)

    if hanten in var and var[hanten] and var[hanten]==var[i]:
        continue
    else:
        print("No");exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input());l=list(map(int,input().split()))

from collections import Counter as co
var=co(l).items()

if n<=4:
    from itertools import permutations as pe
    for i in pe(l,r=None):
        #rは長さ、Noneでiteraterの長さ
        for i in range(n):
            if l[-1+i]^l[(i+1)%n]==l[i]:continue
            break
        else:print("Yes");exit()
    else:print("No");exit()
for i in l:
    hanten=~i&(pow(2,(len(bin(i))-2))-1)

    if hanten in var and var[hanten] and var[hanten]==var[hanten]:
        continue
    else:
        print("No");exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input());l=list(map(int,input().split()))

from collections import Counter as co
var=co(l).items()
ok=0
if n<=4:
    from itertools import permutations as pe
    for i in pe(l,r=None):
        #rは長さ、Noneでiteraterの長さ
        for i in range(n):
            if l[-1+i]^l[(i+1)%n]==l[i]:continue
            break
        else:print("Yes");exit()
    else:print("No");exit()
for i in l:
    hanten=-~i&(1<<20-1)

    if hanten in var and var[hanten] and var[hanten]==var[hanten]:
        continue
    else:
        print("No");exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
Ad = {}
for a in A:
  if a not in Ad:
    Ad[a] = 1
  else:
    Ad[a] += 1
a = len(Ad)
if a == 1:
  for i in Ad.keys():
    if i == 0:
      print('Yes')
    else:
      print('No')
elif n % 3:
  print('No')
elif a == 2:
  x = 0
  for k,v in Ad.items():
    if v != n//3 and v != n//2*2:
      print("No")
      break
    else:
      x ^= k
      if v == n//2*2:
        x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
elif a == 3:
  x = 0
  for k,v in Ad.items():
    if v != n//3:
      print("No")
      break
    else:
      x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
Ad = {}
for a in A:
  if a not in Ad:
    Ad[a] = 1
  else:
    Ad[a] += 1
a = len(Ad)
if n % 3:
  print('No')
elif a == 1:
  for i in Ad.keys():
    if i == 0:
      print('Yes')
    else:
      print('No')
elif a == 2:
  x = 0
  for k,v in Ad.items():
    if v != n//3 and v != n//2*2:
      print("No")
      break
    else:
      x ^= k
      if v == n//2*2:
        x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
elif a == 3:
  x = 0
  for k,v in Ad.items():
    if v != n//3:
      print("No")
      break
    else:
      x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
Ad = {}
for a in A:
  if a not in Ad:
    Ad[a] = 1
  else:
    Ad[a] += 1
a = len(Ad)
if a == 1:
  for i in Ad.keys():
    if i == 0:
      print('Yes')
    else:
      print('No')
elif a == 2:
  x = 0
  for k,v in Ad.items():
    if v != n//3 and v != n//2*2:
      print("No")
      break
    else:
      x ^= k
      if v == n//2*2:
        x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
elif a == 3:
  x = 0
  for k,v in Ad.items():
    if v != n//3:
      print("No")
      break
    else:
      x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())

A = list(map(int, input().split()))

A.append(A[0])
A.append(A[-2])
t = 0
for i in range(n):
    if A[i - 1] ^ A[i + 1] != A[i]:
        t = 1
        break
if t:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

A = list(map(int, input().split()))
t = 0
for i in range(n-1):
    if A[i-1]^A[i+1] == A[i]:
        continue
    else:
        t = 1
        break
if A[-2] ^ A[0] != A[-1]:
    t = 1
if t:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
last=A[-1]
fir=A[0]
A=[last]+A+[fir]
ok=True
for i in range(1,N+1):
    if (A[i-1]^A[i+1])&A[i]!=1:
        ok=False
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
last=A[-1]
fir=A[0]
A=[last]+A+[fir]
ok=True
for i in range(1,N+1):
    if (A[i-1]^A[i+1])!=A[i]:
        ok=False
if ok:
    print("Yes")
else:
    print("No")