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:
# A - XOR Circle
def get_caps(a):
  dic = dict()
  
  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1
  
  return dic


def can_put_on_cap(n):
  global caps
  
  if n in caps.keys():
    if caps[n] > 0:
      caps[n] -= 1
      return True


def get_xor(a, b):
  bin_a = format(a, 'b')
  bin_b = format(b, 'b')

  digit = max(len(bin_a), len(bin_b))
  
  # 2進数のケタ数を揃える
  bin_a = bin_a.zfill(digit)
  bin_b = bin_b.zfill(digit)
  s = ''

  for i in range(len(bin_a)):
    if bin_a[i] == '0' and bin_b[i] == '1':
      s += '1'
    elif bin_a[i] == '1' and bin_b[i] == '0':
      s += '1'
    else:
      s += '0'

  # 10進数に戻す
  return int(s, 2)


import itertools
import copy

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

# 帽子の情報をdictに入れる
caps_original = get_caps(a)

# 1,3番目のラクダを先に決めておく
combis = list(itertools.combinations(a, 2))

for c in combis:
  caps = copy.deepcopy(caps_original)
  count = 0
  xor = 0
  
  if can_put_on_cap(c[0]):
    count += 1
    
    if can_put_on_cap(c[1]):
      camels = [0] * N
      camels[0] = c[0]
      camels[2] = c[1]
  
      # 2番目のラクダの帽子が決まる
      camels[1] = camels[0] ^ camels[2]
      count += 1
      
      if can_put_on_cap(camels[1]):
        count += 1
        
        for i in range(1, N - 2):
          xor = get_xor(camels[i], camels[i + 2])
          
          if can_put_on_cap(xor):
            camels[i + 1] = xor
            count += 1
          else:
            break
      
      xor = get_xor(N - 2, 0)
      
      if can_put_on_cap(xor):
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
S = set(A)
if len(S) > 3:
    print("No")
elif len(S) == 1:
    if A[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(S) == 2:
    if A.count(0) == N // 3 and N % 3 == 0:
        print("Yes")
    else:
        print("No")
else:
    if all(A.count(x) == N // 3 for x in S) and N % 3 == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# A - XOR Circle
def get_xor(index1, index2):
  global a
  
  left = a[index1]
  right = a[index2]
  return left ^ right


def put_on_cap(xor):
  global caps
  
  if is_match(xor):
    caps.add(xor)
  else:
    print('No')
    exit()


def is_match(xor):
  global N
  global caps
  
  if xor < 1 or xor > N:
    return False
  elif xor in caps:
    return False
  else:
    return True


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

caps = set()

# 左端のラクダの処理
xor = get_xor(1, N - 1)
put_on_cap(xor)

for i in range(1, N - 1):
  xor = get_xor(i - 1, i + 1)
  put_on_cap(xor)

# 右端のラクダの処理
xor = get_xor(N - 2, 0)
put_on_cap(xor)

print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
a=L[0]
R=list(set(L))
if len(R)>3:
  print("No")
  exit()
if len(R)==3:
  if R[0]^R[1]!=R[2]:
    print("No")
  else:
    if N%3==0:
      print("Yes")
    else:
      print("No")
elif len(R)==2:
  print("No")
elif len(R)==1:
  if R[0]==0:
    print("Yes")
    exit()
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
a=L[0]
R=list(set(L))
if len(R)>3:
  print("No")
  exit()
if len(R)==3:
  if R[0]^R[1]!=R[2]:
    print("No")
  else:
    if N%3==0:
      print("YES")
    else:
      print("NO")
elif len(R)==2:
  print("NO")
elif len(R)==1:
  if R[0]==0:
    print("YES")
    exit()
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
a=L[0]
R=set(L)
for i in range(1,len(L)):
  if L[i]^a in R:
    ans=[a,L[i]^a,L[i]]
    break
  if i==len(L)-1:
    print("No")
    exit()
for i in range(N-3):
  ans.append(L[-2]^L[-1])
ans=sorted(ans)
L=sorted(L)
if L[-2]^L[0]!=L[-1]:
  print("No")
  exit()
if ans==L:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
a=L[0]
R=set(L)
for i in range(len(L)):
  if L[i]^a in R:
    ans=[a,L[i]^a,L[i]]
    break
  if i==len(L)-1:
    print("No")
    exit()
for i in range(N-3):
  ans.append(L[-2]^L[-1])
ans=sorted(ans)
L=sorted(L)
if L[-2]^L[0]!=L[-1]:
  print("No")
  exit()
if ans==L:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
a=L[0]
R=set(L)
for i in range(len(L)):
  if L[i]^a in R:
    ans=[a,L[i]^a,L[i]]
    break
  if i==len(L)-1:
    print("No")
    exit()
for i in range(N-3):
  ans.append(L[-2]^L[-1])
ans=sorted(ans)
L=sorted(L)
if ans==L:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  a=list(map(int,pin().split()))
  s=1
  for i in a:
    s=s^i 
  if s==1:
    print("Yes")
  else:
    print("No")
  return 

main()

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  a=list(map(int,pin().split()))
  s=0
  for i in a:
    s=s^i 
  if s==0:
    print("Yes")
  else:
    print("No")
  return 

main()

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform=='ios':
	sys.stdin=open('input_file.txt')
	
N=int(input())
A=list(map(int,input().split()))

ans="No"

if N%3!=0:
	if sum(A)==0:
		ans="Yes"
else:
	if A.count(0)==N//3:
		x=0
		for i in range(3):
			if A[i]!=0:
				x=A[i]
				break
		if A.count(x)==2*N//3:
			ans="Yes"
	else:
		x,y,z=A[0],A[1],A[2]
		if A.count(x)==A.count(y) and 		A.count(y)==A.count(z):
			ans="Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform=='ios':
	sys.stdin=open('input_file.txt')
	
N=int(input())
A=list(map(int,input().split()))

p=1

for i in range(N):
	if i!=N-1:
		if A[i]!=A[i-1]^A[i+1]:
			p=0
			break
	else:
		if A[i]!=A[i-1]^A[0]:
			p=0

print('Yes' if p==1 else 'No')

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
A=1
for i in l:
   A^=i
if A==1:
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
l2=[0]*30
for i in l:
   tmp=bin(i).zfill(30)
   for j in range(30):
      if tmp[j]=="1":
         l2[j]=l2[j]^int(tmp[j])
if len(set(l2))==1:
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=a[0]
for i in range(1,n):
    c=c^a[i]
if c==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(N):
    s ^= a[i]
print('Yes' if s == 0 else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] +=1
if len(d) == 1 and list(d.keys())==[0]:
    print('Yes')
elif len(d) == 2:
    for i in d:
        if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
            print('No')
            exit()
    print('Yes')
elif len(d) == 3:
    s = 0
    for i in d:
        s ^= i
        if d[i] * 3 != N:
            print('No')
            exit()
    if s != 0:
        print(1)
        print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] +=1
if len(d) == 1 and d.keys()==[0]:
    print('Yes')
elif len(d) == 2:
    for i in d:
        if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
            print('No')
            exit()
    print('Yes')
elif len(d) == 3:
    s = 0
    for i in d:
        s ^= i
        if d[i] * 3 != N:
            print('No')
            exit()
    if s != 0:
        print(1)
        print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(N):
    s^=a[i]
print('Yes' if s==0 else 'No')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

init = 0
for a_i in A:
    init ^= a_i
if init == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(n):
    b[a[i]] = b[a[i]]+1 if a[i] in b else 1
b = list(b.items())
if len(b) == 1:
    print("Yes") if b[0][0] == 0 else print("No")
elif len(b) == 2:
    print("Yes") if b[0][0] == 0 and b[0][1]*2 == b[1][1] else print("No")
elif len(b) == 3:
    print("Yes") if b[0][0]^b[1][0]^b[2][0] == 0 and b[0][1] == b[1][1] and b[1][1] == b[2][1] else print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(n):
    b[a[i]] = b[a[i]]+1 if a[i] in b else 1
print(b)
b = list(b.items())
print(b)
if len(b) == 1:
    print("Yes") if b[0][0] == 0 else print("No")
elif len(b) == 2:
    print("Yes") if b[0][0] == 0 and b[0][1]*2 == b[1][1] else print("No")
elif len(b) == 3:
    print("Yes") if b[0][0]^b[1][0]^b[2][0] == 0 and b[0][1] == b[1][1] and b[1][1] == b[2][1] else print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(n): b ^= a[i]
print("Yes") if b == 0 else print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
zero=0
sonota=0
for i in range(0,n):
  ans=ans^a[i]
k=-1000
for i in range(n):
  if a[i]==0:
    zero+=1
  elif k==a[i]:
    sonota+=1
  else:
    k=a[i]
    sonota=1
flag=False
if sonota==int(n/3) and zero==int(2*n/3):
  flag=True
if ans==a[0] or sum(a)==0 or flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if n%3>0:
    print('No')
    exit(0)

cnt=sorted(list(Counter(a).items()),key=lambda x:x[0])

if len(cnt)==1 and cnt[0][0]==0:
    print('Yes')
elif len(cnt)==2 and cnt[0][0]==0 and cnt[0][1]==n//3:
    print('Yes')
elif len(cnt)==3 and cnt[0][0]^cnt[1][0]^cnt[2][0]==0 and cnt[0][1]==cnt[1][1]==cnt[2][1]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(0,n):
  ans=ans^a[i]
if ans==a[0]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if n%3>0:
    print('No')
    exit(0)

cnt=sorted(list(Counter(a).items()),key=lambda x:x[0])

if len(cnt)==1 and cnt[0][0]==0:
    print('Yes')
elif len(cnt)==2 and cnt[0][0]==0 and cnt[0][1]==n//3:
    print('Yes')
elif len(cnt)==3 and cnt[0][0]^cnt[1][0]==cnt[2][0] and cnt[0][1]==cnt[1][1]==cnt[2][1]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
  ans=ans^a[i]
if ans==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)

v=list(c.values())
k=list(c.keys())

v=sorted(v)
k=sorted(k)

ans='Yes'
if len(k)==3:
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
elif len(k)==2:
    for j in range(2):
        if j==0:
            if not(k[j]==0 and v[j]==n/3):
                ans='No'
        elif j==1:
            if v[j]!=2*n/3:
                ans='No'
elif len(k)==1 and k[0]==0:
    ans='Yes'
else:
    ans='No'

print(ans)

Submission status: Wrong Answer

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

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)
k=sorted(k)

ans='Yes'
if len(k)==3:
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
elif len(k)==2:
    for j in range(2):
        if (k[j]!=0 or v[j]!=n/3) and j==0:
            ans='No'
        elif v[j]!=2*n/3 and j==1:
            ans='No'
elif len(k)==1 and k[0]==0:
    ans='Yes'
else:
    ans='No'

print(ans)

Submission status: Wrong Answer

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

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)

ans='Yes'
if len(k)==3:
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
elif len(k)==2 and 0 in k:
    for j in range(2):
        if (k[j]!=0 or v[j]!=n/3) and j==0:
            ans='No'
        elif v[j]!=2*n/3 and j==1:
            ans='No'
elif len(k)==1 and k[0]==0:
    ans='Yes'
else:
    ans='No'

print(ans)

Submission status: Wrong Answer

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

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)

ans='Yes'
if len(k)==3:
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
elif len(k)==2 and 0 in k:
    for j in range(2):
        if v[j]!=n/3 and j==0:
            ans='No'
        elif v[j]!=2*n/3 and j==1:
            ans='No'
elif len(k)==1 and k[0]==0:
    ans='Yes'
else:
    ans='No'

print(ans)

Submission status: Wrong Answer

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

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)

ans='Yes'
if len(k)==3:
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
elif len(k)==2:
    for j in range(2):
        if v[j]!=n/3 and j==0:
            ans='No'
        elif v[j]!=2*n/3 and j==1:
            ans='No'
elif len(k)==1 and k[0]==0:
    ans='Yes'
else:
    ans='No'

print(ans)

Submission status: Wrong Answer

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

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)

if len(k)==3:
    ans='Yes'
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
    print(ans)
elif len(k)==2 and v[0]==n//3 and v[1]==2*n//3:
    print('Yes')
elif len(k)==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()))

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)

if len(k)==3 and v==[n//3,n//3,n//3]:
    print('Yes')
elif len(k)==2 and v[0]==n//3:
    print('Yes')
elif len(k)==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()))

from collections import Counter

c=Counter(a)

v=list(c.values())
k = list(c.keys())
k=sorted(k)
if len(k)==3 and v==[n//3,n//3,n//3]:
    print('Yes')
elif len(k)==2 and v[0]==n//3:
    print('Yes')
elif len(k)==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()))

from collections import Counter

c=Counter(a)

v=list(c.values())
k = list(c.keys())
k=sorted(k)
if len(k)==3 and v==[n//3,n//3,n//3]:
    print('Yes')
elif len(k)==2 and k[0]==n//3:
    print('Yes')
elif len(k)==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()))
if len(set(a))==1 and 0 in set(a):
    print("Yes")
    exit()
if len(set(a))>3:
    print("No")
    exit()
if len(set(a))==2 and 0 in set(a):
    print("Yes")
    exit()
if n%3!=0:
    print("No")
    exit()
for i in a:
    for j in a:
        if i==j:
            continue
        for k in a:
            if i==k or j==k:
                continue
            if i^j^k!=0:
                print("No")
                exit()
            if a.count(i)==n//3 and a.count(j)==n//3:
                print("Yes")
                exit()
            else:
                print("No")
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
if sum(A) ==0: #すべてゼロ
  print("Yes")
  exit()

if N%3 != 0:
  print("No")
else:
  dic = {}
  for x in A:
    if x in dic:
      dic[x] += 1
    else:
      dic[x] = 1
  V = list(dic.values())
  if len(V) == 2:
    K = list(dic.keys())
    if K[0] == 0:
      dic[K[1]] = dic[0]*2
      print("Yes")
    elif K[1] == 0:
      dic[K[0]] = dic[0]*2
      print("Yes")
    else:
      print("No")
    exit()  
  if len(V) != 3:
    print("No")
    exit()
  if V[0] == V[1] and V[1] == V[2]:
    K = list(dic.keys())
    if K[0]^K[1] == K[2] and K[1]^K[2] == K[0] and K[2]^K[0] == K[1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
if sum(A) ==0: #すべてゼロ
  print("Yes")
  exit()

if N%3 != 0:
  print("No")
else:
  dic = {}
  for x in A:
    if x in dic:
      dic[x] += 1
    else:
      dic[x] = 1
  V = list(dic.values())
  if len(V) != 3:
    print("No")
    exit()
  if V[0] == V[1] and V[1] == V[2]:
    K = list(dic.keys())
    if K[0]^K[1] == K[2] and K[1]^K[2] == K[0] and K[2]^K[0] == K[1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Submission status: Wrong Answer

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

tmp = a[0]
for i in range(1,n):
    tmp = tmp^a[i]

if tmp == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import xor

N, *A = map(int, open(0).read().split())

print('Yes' if reduce(xor, A) == 0 else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
  s ^= a[i]
if s == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

ans = []
for i in range(N):
    p = i-1
    n = i+1
    if i == 0:
        p = -1
    if i == N-1:
        n = 0
    ans.append(A[p] ^ A[n])

A.sort()
ans.sort()

print('Yes' if A == ans else 'No')

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

ans = []
for i in range(N):
    p = i-1
    n = i+1
    if i == 0:
        p = -1
    if i == N-1:
        n = 0
    ans.append(A[p] ^ A[n] == A[i])

print('Yes' if all(ans) else 'No')

Submission status: Wrong Answer

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

if len(SA) == 1 and list(SA)[0] == 0:
    print("Yes")
    exit()

if len(SA) == 2 and 0 in SA:
    print("Yes")
    exit()

CA = Counter(A)
for v in CA.values():
    if 3 * v != N:
        break
else:
    a, b, c = CA.keys()
    if a ^ b ^ c == 0:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

for i in range(N):
    if A[i-1] ^ A[(i+1)%N] != A[i]:
        break
else:
    print("Yes")
    sys.exit()

A = A[::-1]
for i in range(N):
    if A[i-1] ^ A[(i+1)%N] != A[i]:
        break
else:
    print("Yes")
    sys.exit()
print("No")

Submission status: Wrong Answer

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

tmp = 0
for i in range(n):
    tmp = tmp^a[i]

if tmp == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

for i in range(N):
    if A[i-1] ^ A[(i+1)%N] != A[i]:
        break
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def err():
    print('No')
    quit()
def ok():
    print('Yes')
    quit()

n = inp()
a = inpl()
a.sort()
c = Counter(a)
if a[0] == a[-1] == 0: ok()
if n == 3:
    x,y,z = a
    if x == 0 and y == z: ok()
if len(c.keys()) == 3:
    for x in c.values():
        if x != n//3:
            err()
    x,y,z = c.keys()
    if x^y != z:
        err()
else: err()
ok()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    l = [*Counter(a).values()]
    res = 0
    for s in set(a):
        res ^= s
    if len(l) == 3 and res == 0 and len(set(l)) == 1:
        print('Yes')
    elif len(l) == 2 and a.count(0) == N//3 * 2:
        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()))

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    l = [*Counter(a).values()]
    res = 0
    for s in set(l):
        res ^= s
    if len(l) == 3 and res == 0 and len(set(l)) == 1:
        print('Yes')
    elif len(l) == 2 and a.count(0) == N//3 * 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def err():
    print('No')
    quit()

n = inp()
a = inpl()
c = Counter(a)
if len(c.keys()) == 3:
    for x in c.values():
        if x != n//3:
            err()
    x,y,z = c.keys()
    if x^y != z:
        err()
elif len(c.keys()) == 2:
    x,y = c.values()
    if x != n//2 or y != n//2:
        err()
    if sorted(list(c.keys()))[0]:
        err()
else: err()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    l = [*Counter(a).values()]
    res = 0
    for s in set(a):
        res ^= s
    if len(l) == 3 and res == 0 and len(set(l)) == 1:
        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()))

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    res = 0
    for i in range(N):
        res ^= a[i]
    l = [*Counter(a).values()]
    if res == 0:
        if len(l) == 3 and l[0]^l[1]^l[2] == 0 and len(set(l)) == 1:
            print('Yes')
        else:
            print('No')
    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()))

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    l = [*Counter(a).values()]
    if len(l) == 3 and l[0]^l[1]^l[2] == 0 and len(set(l)) == 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def err():
    print('No')
    quit()

n = inp()
a = inpl()
if n%3: err()
c = Counter(a)
if len(c.keys()) != 3:
    err()
for x in c.values():
    if x != n//3:
        err()
x,y,z = c.keys()
if x^y != z:
    err()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    res = 0
    for i in range(N):
        res ^= a[i]
    l = Counter(a).values()
    if len(l) == 3 and len(set(l)) == 1 and res == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
if 0 in C and C[0]==N:
    print("Yes")
elif N%3==0:
    C = list(C.items())
    if len(C)==3:
        a = C[0][0]
        b = C[1][0]
        c = C[2][0]
        if C[0][1]==C[1][1]==C[2][1] and a==b^c:
            print("Yes")
        else:
            print("No")
    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()))

if N % 3 > 0:
    print('Yes') if len(set(a)) == 1 and a[0] == 0 else print('No')
else:
    res = 0
    for i in range(N):
        res ^= a[i]
    l = Counter(a).values()
    if len(l) == 3 and len(set(l)) == 1 and res == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3 > 0:
    print('Yes') if len(set(a)) == 1 and a[0] == 0 else print('No')
else:
    l = Counter(a).values()
    if len(l) == 3 and len(set(l)) == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3 > 0:
    print('Yes') if len(set(a)) == 1 else print('No')
else:
    l = [*Counter(a).values()]
    if len(l) == 3 and len(set(l)) == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
if N==3:
    if A[0]==A[1]^A[2]:
        print("Yes")
    else:
        print("No")
elif N%3==0:
    flag = 0
    for i in range(3,N):
        if A[i]!=A[i-3]:
            flag = 1
            break
    if flag==0:
        if A[0]==A[1]^A[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    flag = 0
    for i in range(N):
        if A[i]!=0:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
if N==3:
    if A[0]==A[1]^A[2]:
        print("Yes")
    else:
        print("No")
elif N%3==0:
    flag = 0
    for i in range(3,N):
        if A[i]!=A[i-3]:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
else:
    flag = 0
    for i in range(N):
        if A[i]!=0:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
if N==3:
    if A[0]==A[1]^A[2]:
        print("Yes")
    else:
        print("No")
elif N%3==0:
    flag = 0
    for i in range(3,N):
        if A[i]!=A[i-3]:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
else:
    flag = 0
    for i in range(1,N):
        if A[i]!=A[0]:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")