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:
from collections import Counter

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

c = Counter(a)

if c[0] == N:
    print("Yes")
elif N%3 == 0 and c[0] == N//3:
    for A in a:
        if c[A] == (2*N)//3:
            print("Yes")
            break
    else:
        print("No")
elif N%3 == 0:
    tmp = []
    for A in a:
        if c[A] == N//3:
            tmp.append(A)
    if len(set(tmp)) == 3 and tmp[0] ^ tmp[1] ^ tmp[2] == 0:
        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 c[0] == N:
    print("Yes")
elif N%3 == 0 and c[0] == N//3:
    for A in a:
        if c[A] == (2*N)//3:
            print("Yes")
            break
    else:
        print("No")
elif N%3 == 0:
    tmp = []
    for A in a:
        if c[A] == N//3:
            tmp.append(A)
    if len(set(tmp)) == 3:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

sa = set(a)

for i in range(1,N):
    tmp = [a[0], a[i]]
    for _ in range(N-2):
        tmp.append(tmp[-2] ^ tmp[-1])
        if tmp[-1] not in set(sa):
            break
    else:
        if tmp[-1] ^ tmp[1] == tmp[0]:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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

sa = set(a)

tmp = [a[0]]
for i in range(1,N):
    tmp.append(a[i])
    for _ in range(N-2):
        tmp.append(tmp[-2] ^ tmp[-1])
        if tmp[-1] not in set(sa):
            break
    else:
        if tmp[-1] ^ tmp[1] == tmp[0]:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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

sa = set(a)

tmp = [a[0]]
for i in range(1,N):
    tmp.append(a[i])
    for j in range(N-2):
        tmp.append(tmp[-2] ^ tmp[-1])
        if tmp[-1] not in set(sa):
            break
    else:
        if tmp[-2] ^ tmp[-1] == tmp[0]:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter

def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    ac=Counter(A)
    aci=list(ac.items())
    aci.sort()
    if aci[0]==(0,n):
        print("Yes")
        sys.exit()
    elif n%3==0 and len(aci)==2:
        if aci[0]==(0,n//3) and aci[1][1]==n//3*2:
            print("Yes")
            sys.exit()
    elif n%3==0 and len(aci)==3:
        if aci[0][1]==aci[1][1] and aci[1][1]==aci[2][1]:
            print("Yes")
            sys.exit()
    print("No")


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter

def main():
    n=int(input())
    if n%3!=0:
        print("No")
        sys.exit()
    A=[int(_) for _ in input().split()]
    ac=Counter(A)
    aci=list(ac.items())
    aci.sort()
    if aci[0]==(0,n):
        print("Yes")
        sys.exit()
    elif len(aci)==2:
        if aci[0]==(0,n//3) and aci[1][1]==n//3*2:
            print("Yes")
            sys.exit()
    elif len(aci)==3:
        if aci[0][1]==aci[1][1] and aci[1][1]==aci[2][1]:
            print("Yes")
            sys.exit()
    print("No")


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    if n==3 and A[0]^A[1]==A[2]:
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

def print_yes():
    print('Yes')
    exit(0)

def print_no():
    print('No')
    exit(0)

if not any(a):
    print('Yes')
else:
    if N % 3 == 0:
        counter = Counter(a)
        # print(counter)
        if len(counter) == 3:
            for i in counter.values():
                if i != N / 3:
                    print_no()
            print_yes()
        elif len(counter) == 2:
            if a.count(0) == N/3:
                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()))
num = list(set(a))

if len(num) == 1 and num[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(num) == 3:
        s = num.count(num[0])
        t = num.count(num[1])
        u = num.count(num[2])
        if s == t and t == u and u == s and num[0] ^ num[1] == num[2]:
            print('Yes')
        else:
            print('No')
    elif len(num) == 2:
        if num.count(max(num)) == num.count(0) * 2:
            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()))
num = list(set(a))

if N % 3 == 0 and len(num) == 3 and num[0] ^ num[1] == num[2]:
    print('Yes')
elif len(num) == 1 and num[0] == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
num = list(set(a))

if N % 3 == 0 and len(num) == 3 and num[0] ^ num[1] == num[2]:
    print('Yes')
elif len(num) <= 2 and num[0] == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
count = Counter(a)
flag = False
if max(count.values())==n:
    flag = True
else:
    if count[0]==n//3 and max(count.values())==(n*2//3):
        flag = True
        
    else:
        flag = True
        for i in count:
            if count[i]!=n/3:
                flag = False
print('Yes' if flag==True else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if n%3==0:
  d={}
  for ai in a:
    if ai not in d:
      d[ai]=a.count(ai)
      if len(d)==4:
        break
  sa=list(set(a))
  if len(sa)==3 and sa[0]^sa[1]==sa[2] and d[sa[0]]==d[sa[1]] and d[sa[0]]==d[sa[2]]:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=[int(i) for i in input().split()]
if n%3!=0:
  print('No')
  sys.exit()
b=set(a)
if len(b)!=3:
  print('No')
  sys.exit()
if list(b)[0]^list(b)[1]^list(b)[2]!=0:
  print('No')
  sys.exit()
s=[a.count(i) for i in list(b)]
if 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()))

for i in range(0, len(A) - 2):
    if A[i] ^ A[i + 1] ^ A[i + 2]:
        print("No")
        exit(0)

if (A[0] ^ A[1] ^ A[-1]) or (A[0] ^ A[-1] ^ A[-2]):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
c = list(b.items())
if len(b)==0 and (b[0]==n):
    print("Yes")
elif len(b)==2 and n%3==0 and b[0]==n//3:
    print("Yes")
elif len(b)==3 and c[0][0]^c[1][0]^c[2][0]==0 and c[0][1]==c[1][1]==c[2][1]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if all(a[i-1]^a[(i+1)%n]==a[i] for i in range(n)):print("Yes")
else:print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = a + a[:2]
ans = "Yes"
for i in range(n):
  if a[i]^a[i+2] != a[i+1]:
    ans = "No"
    break
  j = i
print(ans)

Submission status: Wrong Answer

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

ans="No"
if a[0]^a[1]^a[2]==0 and a[-1]^a[0]^a[1]==0 and a[-2]^a[-1]^a[0]==0:
  ans="Yes"

if ans=="Yes":
  for i in range(3,N):
    if a[i]!=a[i-3]:
      ans="No"
      break
      
print(ans)

Submission status: Wrong Answer

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

ans="No"
if a[0]^a[1]^a[2]==0:
  ans="Yes"

if ans=="Yes":
  for i in range(3,N):
    if a[i]!=a[i-3]:
      ans="No"
      break
      
print(ans)

Submission status: Wrong Answer

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

ans="Yes"
if a[0]^a[1]^a[2]==0:
  ans="No"

if ans=="Yes":
  for i in range(3,N):
    if a[i]!=a[i-3]:
      ans="No"
      break
      
print(ans)

Submission status: Wrong Answer

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

ans="No"
if a[0]^a[1]^a[2]==0:
  for i in range(3,N):
    if a[i]!=a[i-3]:
      ans="No"
      break
      
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if 0 in ca and ca[0] == n:
    print("Yes")
elif n % 3 == 0 and 0 in ca and ca[0] == n // 3 and len(ca) == 2:
    print("Yes")
elif n % 3 == 0 and len(ca) == 3:
    values = []
    for c in ca:
        if ca[c] == n // 3:
            values.append(c)
    if len(values) == 3:
        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()))
ca = Counter(a)

if 0 in ca and ca[0] == n:
    print("Yes")
elif 0 in ca and ca[0] == n // 3:
    # x 0 x x 0 x (x)
    for c in ca:
        if ca[c] == 2 * n // 3:
            print("Yes")
    else:
        print("No")
else:
    values = []
    for c in ca:
        if ca[c] == n // 3:
            values.append(c)
    if len(values) == 3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

ans="No"
if a[-3]==a[0]:
  if a[-2]==a[1]:
    if a[-1]==a[2]:
      ans="Yes"
      
if ans=="Yes":
  for i in range(3,N):
    if a[i]!=a[i-3]:
      ans="No"
      break
      
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
B = list(set(A))
if len(B) == 2:
    B.sort()
    B.append(B[1])
if (len(B) == 3 and B[0]^B[1] == B[2] and n%3 == 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
B = list(set(A))
if len(B) == 3 and n%3 == 0 and (B[0]^B[1]==B[2]):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
ans = "Yes"

if(a[1]^a[N-1] != a[0]):
    ans = "No"
elif(a[N-2]^a[0] != a[N-1]):
    ans = "No"
else:
    for i in range(1, N-1):
        if(a[i-1]^a[i+1] != a[i]):
            ans ="No"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
# Nが3の倍数かつ、配列が「aがm個とbがm個とcがm個」かつ、a^b == c ならTrue

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

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

m = n // 3
nums.sort()
for i in range(m-1):
    if nums[i] != nums[i+1] or nums[m+i] != nums[m+i+1] or nums[2*m+i] != nums[2*m+i+1]:
        print('No')
        exit()

if nums[0] ^ nums[m] == nums[2*m]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# Nが3の倍数かつ、配列が「aがm個とbがm個とcがm個」かつ、a^b == c ならTrue

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

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

m = n // 3
nums.sort()
for i in range(m-1):
    if nums[i] != nums[i+1] or nums[m+i] != nums[m+i+1] or nums[2*m+i] != nums[2*m+i*1]:
        print('No')
        exit()

if nums[0] ^ nums[m] == nums[2*m]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
if b.count(0)==n:
    print("Yes")
elif n%3==0:
    if b.count(0)==n//3 and b.count(b[n-1])==n-(n//3):
        print("Yes")
    elif b.count(b[0])==n//3 and b.count(b[n//3])==n//3 and b.count(b[n-1])==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()))
a1 = a[0]
a1_cnt = a.count(a[0])
a = [x for x in a if x != a[0]]
if len(a) == 0:
  if a1 == 0:
    print("Yes")
  else:
    print("No")
  exit()
a2 = a[0]
a2_cnt = a.count(a[0])
a = [x for x in a if x != a[0]]
if len(a) == 0:
  if min(a1, a2) != 0:
    print("No")
  else:
    if a1_cnt == a2_cnt:
      print("Yes")
    else:
      print("No")
  exit()
a3 = a[0]
a3_cnt = a.count(a[0])
if a1 ^ a3 == a2 and a1_cnt == a2_cnt and a2_cnt == a3_cnt and a1_cnt == n//3:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if a.count(a[0]) != n//3 or n%3 != 0:
  print("No")
  exit()
a1 = a[0]
a = [x for x in a if x != a[0]]
if a.count(a[0]) != n//3:
  print("No")
  exit()
a2 = a[0]
a = [x for x in a if x != a[0]]
a3 = a[0]
if a1 ^ a3 == a2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
from functools import reduce

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

c = Counter(a)
if len(c) > 3:
    print('No')
else:
    if len(c) == 1 and c.get(0):
        print('Yes')
    elif len(c) == 2 and c.get(0) == n / 3:
        print('Yes')
    elif len(c) == 3 and reduce(lambda x, y: x^y, c.keys()) == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
a=list(map(int,input().split()))
if (N%3)==0:
    c=collections.Counter(a)
    l=list(set(a))
    if ((len(l)==3)and(c[l[0]]==c[l[1]]==c[l[2]])and(l[0]^l[1]==l[2]))or((len(l)==1)and(l[0]==0)):
        print("Yes")
    else:
        print("No")
else:
    if max(a)==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
a=list(map(int,input().split()))
if (N%3)==0:
    c=collections.Counter(a)
    l=list(set(a))
    if (len(l)==3)and(c[l[0]]==c[l[1]]==c[l[2]])and(l[0]^l[1]==l[2]):
        print("Yes")
    else:
        print("No")
else:
    if max(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:
    if a[0]^a[1]==a[2]:
        print("Yes")
    else:
        print("No")
else:
    if max(a)==0:
        print("Ys")
    else:
        print("N")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
if len(a)==3:
    if a[0]^a[1]==a[2]:
        print("Yes")
    else:
        print("No")
else:
    if max(a)==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int, input().split()))
Flag=True

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-2):
      if Flag==True:
        if bin(a[i] ^ a[i+2])!=bin(a[i+1]):
          Flag=False
          break  
    if Flag==True:
      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()))
C = [A[-1]] + A + [A[0]]

flag = True
for i in range(1, N+1):
  xor = i ^ (C[i-1] ^ C[i+1])
  if xor != 0:
    flag = False
    break

if flag: print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
C = [A[-1]] + A + [A[0]]

flag = True
for i in range(1, N+1):
  xor = C[i-1] ^ C[i+1]
  if i != xor:
    flag = False
    break

if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

a_set = set(a)

if len(a_set) > 3:
    print("No")
elif len(a_set) == 3:
    x, y, z = a_set
    if a.count(x) == a.count(y) == a.count(z):
        if x ^ y ^ z == 0:
            print("Yes")
        else:
            print("No")
elif len(a_set) == 2:
    x, y = sorted(a_set)
    if x == 0:
        if a.count(x) * 3 == N:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    if sum(a_set) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
def main():
    hats = int(input())
    number = list(map(int, input().split()))
    count = {}
    for n in number:
        if n in count:
            count[n] += 1
        else:
            count[n] = 1
    answer = False
    key = list(count.keys())
    val = list(count.values())
    if len(key) == 1 and key == [0]:
        answer = True
    elif len(key) == 2 and hats % 3 == 0:
        if (key[0] == 0 and val[0] == 2 * hats // 3 and val[1] == hats // 3) or \
                (key[1] == 0 and val[1] == 2 * hats // 3 and val[0] == hats // 3):
            answer = True
    elif len(key) == 3 and hats % 3 == 0:
        if key[0] ^ key[1] ^ key[2] == 0 and val[1] == val[2] == val[0] == hats // 3:
            answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    hats = int(input())
    number = list(map(int, input().split()))
    count = {}
    for n in number:
        if n in count:
            count[n] += 1
        else:
            count[n] = 1
    answer = False
    key = list(count.keys())
    val = list(count.values())
    if hats % 3 == 0:
        if len(key) == 1 and key == [0]:
            answer = True
        elif len(key) == 2:
            if (key[0] == 0 and val[0] == 2 * hats // 3 and val[1] == hats // 3) or \
                    (key[1] == 0 and val[1] == 2 * hats // 3 and val[0] == hats // 3):
                answer = True
        elif len(key) == 3:
            if key[0] ^ key[1] ^ key[2] == 0 and val[1] == val[2] == val[0] == hats // 3:
                answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int, input().split())))
a = [1,2,3]
if arr == a:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
allzero = True
element = {}
for i in a:
    if i != 0:
        allzero = False
    if i not in element.keys():
        element[i] = 0
    element[i] += 1
if allzero:
    print('Yes')
else:
    if n % 3 != 0:
        print('No')
    elif len(element) == 2:
        if 0 in element.keys() and element[0] == n//3:
            print('Yes')
    elif len(element) == 3:
        judge = 0
        for k, v in element.items():
            judge ^= k
            if v != n//3:
                print('No')
                break
        else:
            if judge == 0:
                print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
allzero = True
element = {}
for i in a:
    if i != 0:
        allzero = False
    if i not in element.keys():
        element[i] = 0
    element[i] += 1
if allzero:
    print('Yes')
else:
    if sum(element.values()) % 3 != 0:
        print('No')
    elif len(element) == 2:
        if 0 in element.keys() and element[0] == n//3:
            print('Yes')
    elif len(element) == 3:
        judge = 0
        for k, v in element.items():
            judge ^= k
            if v != n//3:
                break
        else:
            if judge == 0:
                print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[int(x) for x in input().split()]
for i in range(N-2):
    if not a[i]^a[i+2]==a[i+1]:
        print('No')
        exit()
if not a[-2]^a[0]==a[-1]:
    print('No')
    exit()
if not a[-1]^a[1]==a[0]:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
X = set(A)
if len(X) <= 2:
    if 0 in X:
        ans = 1
    else:
        ans = 0
elif len(X) == 3:
    Y = list(X)
    if A.count(Y[0]) == A.count(Y[1]) == A.count(Y[2]):
        ans = 1
        for i in range(40):
            Z = list(map(lambda x: x % 2,Y))
            Y = list(map(lambda x: x // 2,Y))
            Z.sort()
            #print(Z)
            if Z != [0,1,1] and Z != [0,0,0]:
                ans = 0
                break
    else:
        ans = 0
elif len(X) >= 4:
    ans = 0
if ans == 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
x='No'
p=len(set(a))
if p==1:
  if a[0]==0:
    x='Yes'
elif p==2:
  if n%3==0:
    if a.count(0)==n//3:
      x='Yes'
elif p==3:
  if n%3==0:
    b=set(a)
    t=0
    for i in b:
      t=t^i
    if t==0:
      x='Yes'
print(x)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
x='No'
if len(set(a))==1:
  if a[0]==0:
    x='Yes'
elif len(set(a))==2:
  if n%3==0:
    if a.count(0)==n//3:
      x='Yes'
else:
  if n%3==0:
    b=set(a)
    t=0
    for i in b:
      t=t^i
    if t==0:
      x='Yes'
print(x)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    if A[0] != 0 and A[0] != 1:
        return print("No")
    elif A[0] == 1:
        for i in range(N-1):
            if A[i] + 1 != A[i+1]:
                return print("No")
        c = A[-1] + 1
        ans = {2**i for i in range(2, 30)}
        if c in ans:
            return print("Yes")
        else:
            return print("No")
    elif A[0] == 0:
        from collections import Counter
        c = dict(Counter(A))
        if len(c.keys()) == 1:
            # all 0
            return print("Yes")
        elif len(c.keys()) > 2 or c[0] > 1 or N > 3:
            return print("No")
        else:
            return print("Yes")
    else:
        raise RuntimeWarning


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main(): 
    n = int(input())
    a = [ int(x) for x in input().split() ]

    d = {}
    for aa in a:
        d[aa] = d.get(aa, 0) + 1

    if d.get(0, 0) == n:
        print("Yes")
        return 0
    L = sorted(list(d.items()))
    if n % 3 == 0 and len(L) == 2 and (L[0][0] == 0 and L[0][1] == n//3) and L[1][1] == n//3*2:
        print("Yes")
        return 0
    
    if n % 3 == 0 and len(L) == 3 and L[0][0]^L[1][0]^L[2][0] == 0:
        print("Yes")
        return 0

    print("No")

main()

Submission status: Wrong Answer

Solution code:
def main(): 
    n = int(input())
    a = [ int(x) for x in input().split() ]

    d = {}
    for aa in a:
        d[aa] = d.get(aa, 0) + 1

    if d.get(0, 0) == n:
        print("Yes")
        return 0
    L = sorted(list(d.items()))
    if n % 3 == 0 and len(L) == 2 and (L[0][0] == 0 and L[0][1] == n//3) and L[0][1] == n//3*2:
        print("Yes")
        return 0
    
    if n % 3 == 0 and len(L) == 3 and L[0][0]^L[1][0]^L[2][0] == 0:
        print("Yes")
        return 0

    print("No")

main()

Submission status: Wrong Answer

Solution code:
def main(): 
    n = int(input())
    a = [ int(x) for x in input().split() ]

    d = {}
    for aa in a:
        d[aa] = d.get(aa, 0) + 1

    if d.get(0, 0) == n:
        print("Yes")
        return 0
    L = sorted(list(d.items()))
    if n % 3 == 0 and len(L) == 2 and (L[0][0] == 0 and L[0][1] == n//3*2) and L[0][1] == n//3:
        print("Yes")
        return 0
    
    if n % 3 == 0 and len(L) == 3 and L[0][0]^L[1][0]^L[2][0] == 0:
        print("Yes")
        return 0

    print("No")

main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
*a, = map(int, input().split())

if sum(a) == 0:
    print("Yes")
elif n % 3 != 0:
    print("No")
else:
    can_put_on = False
    c = Counter(a)
    if c[0] == n//3 and len(c) == 2:
        can_put_on = True
    if all(v == n//3 for v in c.values()):
        can_put_on = True
    print("Yes" if can_put_on else "No")

Submission status: Wrong Answer

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

for i in range(n):
    for j in range(i+1, n):
        x = a[i]
        y = a[j]
        if x ^ y not in a:
            print("No")
            exit()
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if A.count(B[0])==2*A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if A.count(B[0])==A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    a=list(map(int,readline().split()))

    c=Counter(a)
    c=sorted(c.items())
    if N%3!=0:  #Nが3の倍数じゃない時
        if len(c)==1 and c[0][0]=="0":
            print("Yes")
        else:
            print("No")

    elif N%3==0:  #Nが3の倍数の時
        if len(c)==1 and c[0][0]==0:
            print("Yes")
        elif len(c)==2 and c[0][0]==0 and c[0][1]==N//3:
            print("Yes")
        elif len(c)==3 and c[0][1]==N//3 and c[1][1]==N//3 and c[2][1]==N//3 and c[0][0]^c[1][0]^c[2][0]==0:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    a=list(map(int,readline().split()))

    c=Counter(a)
    c=sorted(c.items())
    if N%3!=0:  #Nが3の倍数じゃない時
        if len(c)==1 and c[0][0]=="0":
            print("Yes")
        else:
            print("No")

    elif N%3==0:  #Nが3の倍数の時
        if len(c)==1 and c[0][0]==0:
            print("Yes")
        elif len(c)==2 and c[0][0]==0 and c[0][1]==N//3:
            print("Yes")
        elif len(c)==3 and c[0][1]==2 and c[1][1]==2 and c[2][1]==2 and c[0][0]^c[1][0]^c[2][0]==0:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]
c = Counter(a)
b = len(c.keys())

def check():
    if 0 in c.keys():
        if b==1 or (b==2 and c[0]==N//3):
            return True
    elif b==3:
        s, t, u = c.keys()
        if c[s]//3==c[t]//3==c[u]//3:
            return True
    return False

print("Yes" if check() else "No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N = int(input())
A = [int(i) for i in input().split()]
flag = True
if N%3==0:
  d = defaultdict(int)
  if len(set(A)) == 3:
    for i in range(N):
      d[A[i]] += 1
    for i, j in d.items(): 
      if j != N//3:
        flag = False
        
  elif len(set(A)) == 2:
    for i in range(N):
      d[A[i]] += 1
    for i, j in d.items():
      if i != 0 and j != 2*N//3:
        flag = False
      elif i==0 and j != N//3:
        flag = False
else:
  if list(set(A))[0]!=0 and len(set(A))!=1:
    flag = False
  
print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
flag = False

for i in range(1,N-1):
  if A[i] == (A[i-1]^A[i+1]):
    flag = True
if A[0] != (A[-1]^A[1]):
  flag = False
if A[-1] != (A[-2]^A[0]):
  flag = False

if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
flag = False

for i in range(1,N-1):
  if A[i] == (A[i-1]^A[i+1]):
    flag = True
if A[0] == (A[-1]^A[1]):
  flag = True
if A[-1] == (A[-2]^A[0]):
  flag = True

if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = input()
num = input().split(" ")
ichi = int(-1)
ni = int(-1)
san = int(-1)
unko = str()
for i in range(int(N)):
  if int(num[i]) == ichi:
    pass
  else:
    if int(num[i]) == ni:
      pass
    else:
      if int(num[i]) == san:
        pass
      else:
        if ichi == -1:
          ichi = int(num[i])
        elif ni == -1:
          ni = int(num[i])
        elif san == -1:
          san = int(num[i])
        else:
          unko = "unko"
          break

if int(N) % 3 != 0 and ni != -1:
    unko = "unko"
if ni == -1 and int(num[0]) != 0:
    unko = "unko"
else:
    pass

if unko != "unko":
  print("Yes")
else:
  print("No")