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)

judge = False
if 0 in c and c[0] == n:
  judge = True
if n % 3 == 0:
  judge1, judge2 = False, 0
  num = 0
  value = 0
  for k, v in c.items():
    num += 1
    if v == n // 3:
      if k == 0:
        judge1 = True
      judge2 += 1
      value ^= v
  if judge1 and num == 2:
    judge = True
  if judge2 == num == 3 and value == 0:
    judge = True

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

Submission status: Wrong Answer

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

judge = False
if 0 in c and c[0] == n:
  judge = True
if n % 3 == 0:
  judge1, judge2 = False, 0
  num = 0
  for k, v in c.items():
    num += 1
    if v == n // 3:
      if k == 0:
        judge1 = True
      judge2 += 1
  if judge1 and num == 2:
    judge = True
  if judge2 == num == 3:
    judge = True

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

Submission status: Wrong Answer

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

judge = False
if 0 in c and c[0] == n:
  judge = True
if n % 3 == 0:
  judge1, judge2 = False, 0
  num = 0
  for k, v in c.items():
    num += 1
    if v == n // 3:
      if k == 0:
        judge1 = True
      judge2 += 1
  if judge1 and num == 2:
    judge = True
  if judge2 == 3:
    judge = True

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

Submission status: Wrong Answer

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

judge = False
if 0 in c and c[0] == n:
  judge = True
if n % 3 == 0:
  judge1, judge2 = False, 0
  num = 0
  for k, v in c.items():
    num += 1
    if v == n // 3:
      if k == 0:
        judge1 = True
      else:
        judge2 += 1
  if judge1 and num == 2:
    judge = True
  if judge2 == num == 3:
    judge = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

ans = True
for i in range(30):
  judge = np.sum(a % 2)
  if judge < (n - 1) // 2 + 1 and judge != 0:
    ans = False
    break
  a = a // 2

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))
n = N // 3
dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

ans = True

if len(dic) > 3:
    ans = False

elif len(dic) == 3:
    for k in dic:
        if dic[k] != n:
            ans = False

elif len(dic) == 2:
    for k in dic:
        if k == 0:
            if dic[k] != n:
                ans = False
        else:
            if dic[k] != n * 2:
                ans = False

else:
    keys = dic.keys()
    if not 0 in keys:
        ans = False

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

ans = True

if len(dic) > 3:
    ans = False

elif len(dic) == 3:
    for k in dic:
        if dic[k] != N // 3:
            ans = False
            break

elif len(dic) == 2:
    keys = dic.keys()
    n = N // 3
    for k in keys:
        if k == 0:
            if dic[k] != n:
                ans = False
        else:
            if dic[k] != n * 2:
                ans = False

else:
    keys = dic.keys()
    if 0 not in keys:
        ans = False

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

ans = True

if len(dic) > 3:
    ans = False

elif len(dic) == 3:
    for k in dic:
        if dic[k] != N // 3:
            ans = False
            break

else:
    keys = dic.keys()
    if 0 not in keys:
        ans = False

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

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
a = l()

for i in a:
  ans ^= i

print("Yes" if ans == 0 else "No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
a.insert(0,a[-1])
a.append(a[1])
for i in range(1,N+1):
    if a[i-1]^a[i+1]!=a[i]:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import*
n,*A=map(int,open(0).read().split());C=Counter(A).items();f=1;l=len(C)
if l==3:f=(len(set(c[1]for c in C))>1)+n%3>0
elif l==2:f=(abs(sum(c[1]*(-1)**i for i,c in enumerate(C)))!=n//3)+n%3>0
else:f=(l!=1)+A[0]>0
print('YNeos'[f::2])

Submission status: Wrong Answer

Solution code:
from collections import*
n,*A=map(int,open(0).read().split());C=Counter(A).items();f=1;l=len(A)
if l==3:f=(len(set(c[1]for c in C))>1)+(n%3)>0
elif l==2:f=(abs(C[1][1]-C[0][1])!=n//3)+n%3>0
else:f=(l!=1)*(A[0]>0)
print('YNeos'[f::2])

Submission status: Wrong Answer

Solution code:
from collections import*
n,*A=map(int,open(0).read().split());C=Counter(A).items();f=1;l=len(A)
if l==3:f=len(set(c[1]for c in C))*(n%3)>0
elif l==2:f=(abs(C[1][1]-C[0][1])!=n//3)+n%3>0
else:f=(l!=1)*(A[0]>0)
print('YNeos'[f::2])

Submission status: Wrong Answer

Solution code:
input();x=0
for i in map(int,input().split()):x^=i
print("YNeos"[x>0::2])

Submission status: Wrong Answer

Solution code:
input();x=0
for i in map(int,input().split()):x^=i
print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums =list(map(int, input().split()))
a = {}
INF = 10**5
for num in nums:
  if not num in a:
    a[num] = 1
  else:
    a[num] += 1
  if len(a) > 3:
    print('No')
    exit()
def same_count(dic):
  v_max = 0
  v_min = INF
  for v in dic.values():
    v_max = max(v_max, v)
    v_min = min(v_min, v)
  return v_max == v_min
def xor_zero(dic):
  a = 0
  for k in dic.keys():
    a ^= k
  return True if a == 0 else False

def double_count(dic):
  v_max = 0
  v_min = INF
  for v in dic.values():
    v_max = max(v_max, v)
    v_min = min(v_min, v)
  return v_max//v_min == 2 and dic[0] == v_min

answer = False
if len(a) == 3:
  answer = same_count(a) and xor_zero(a)
elif len(a) == 2:
  answer = 0 in a.keys() and double_count(a)
elif len(a) == 1:
  answer = 0 in a.keys()
if answer:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
nums =list(map(int, input().split()))
a = {}
INF = 10**5
for num in nums:
  if not num in a:
    a[num] = 1
  else:
    a[num] += 1
  if len(a) > 3:
    print('No')
    exit()
def same_count(dic):
  v_max = 0
  v_min = INF
  for v in dic.values():
    v_max = max(v_max, v)
    v_min = min(v_min, v)
  return v_max == v_min
def xor_zero(dic):
  a = 0
  for k in dic.keys():
    a ^= k
  return True if a == 0 else False

answer = False
if len(a) == 3:
  answer = same_count(a) and xor_zero(a)
elif len(a) == 2:
  answer = 0 in a.keys() and same_count(a)
elif len(a) == 1:
  answer = 0 in a.keys()
if answer:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
nums =list(map(int, input().split()))
a = {}
INF = 10**5
for num in nums:
  if not num in a:
    a[num] = 1
  else:
    a[num] += 1
  if len(a) > 3:
    print('No')
    exit()
def same_count(dic):
  v_max = 0
  v_min = INF
  for v in dic.values():
    v_max = max(v_max, v)
    v_min = min(v_min, v)
  return v_max == v_min
answer = False
if len(a) == 3:
  answer = same_count(a)
elif len(a) == 2:
  answer = 0 in a.keys() and same_count(a)
elif len(a) == 1:
  answer = 0 in a.keys()
if answer:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
nums =list(map(int, input().split()))
a = {}
INF = 10**5
for num in nums:
  if not num in a:
    a[num] = 1
  else:
    a[num] += 1
  if len(a) > 3:
    print('No')
    exit()
if len(a) >= 2:
  max_v = 0
  min_v = INF
  for v in a.values():
    max_v = max(max_v, v)
    min_v = min(min_v, v)
  if max_v == min_v:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N % 3 != 0:
    res = 'Yes'
    for i in range(N):
        if a_ls[i] != 0:
            res = 'No'
else:
    res = 'Yes'
    c = Counter(a_ls)
    if len(c) > 3:
        res = 'No'
    if len(c) == 3:
        if not list(c.values())[0] == list(c.values())[1] == list(c.values())[2]:
            res = 'No'
        for i in c.keys():
            for j in c.keys():
                for k in c.keys():
                    if i!=j and j!=k and k!=i and not i^j==k:
                        res = 'No'
    else:
        for i in range(N):
            if a_ls[i] != 0:
                res = 'No'
        
print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
a = list(set(A))


if len(a) >= 4:
    ans = False

elif len(a) == 3:
    a, b, d = a
    if c[a] == c[b] == c[d] and a^b == c and c^b == a and a^c == b:
        ans = True
    else:
        ans = False

elif len(a) == 2:
    a, b = sorted(a)
    if a == 0 and c[a] == N/3 and c[b] == (N/3)*2:
        ans = True
    else:
        ans = False

elif len(a) == 1:
    if sum(a) == 0:
        ans = True
    else:
        ans = False

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
a = list(set(A))


if len(a) >= 4:
    ans = False

elif len(a) == 3:
    ans = True
    for i in c.values():
        if i != N/3:
            ans = False
            break

elif len(a) == 2:
    a, b = sorted(a)
    if a == 0 and c[a] == N/3 and c[b] == (N/3)*2:
        ans = True
    else:
        ans = False

elif len(a) == 1:
    if sum(a) == 0:
        ans = True
    else:
        ans = False

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
a = list(set(A))


if len(a) >= 4:
    ans = False

elif len(a) == 3:
    ans = True
    for i in c.values():
        if i != N/3:
            ans = False
            break

elif len(a) == 2:
    a, b = sorted(a)
    if a == 0 and c[a] == N/3 and c[b] == (N/3)*2:
        ans = True
    else:
        ans = False

elif len(a) == 1:
    if a == [0]:
        ans = True
    else:
        ans = False

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
a = list(set(A))


if len(a) >= 4:
    ans = False

elif len(a) == 3:
    ans = True
    for i in c.values():
        if i != N/3:
            ans = False
            break

elif len(a) == 2:
    if c.most_common()[1][0] == 0 and c.most_common()[0][1] == (N/3)*2 and c.most_common()[1][1] == N/3:
        ans = True
    else:
        ans = False

elif len(a) == 1:
    if a == [0]:
        ans = True
    else:
        ans = False

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
a = list(set(A))


if len(a) >= 4:
    ans = False

elif len(a) == 3:
    ans = True
    for i in c.values():
        if i != N/3:
            ans = False
            break

elif len(a) == 2:
    if c.most_common()[0][0] == 0 and c.most_common()[0][1] == (N/3)*2 and c.most_common()[1][1] == N/3:
        ans = True
    else:
        ans = False

elif len(a) == 1:
    if a == [0]:
        ans = True
    else:
        ans = False

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
a = list(set(A))


if len(a) >= 4:
    ans = False

elif len(a) == 3:
    ans = True
    for i in c.values():
        if i != N/3:
            ans = False
            break

elif len(a) == 2:
    if c.most_common()[0][0] == 0 and c.most_common()[0][1] == (3/N)*2 and c.most_common()[1][1] == N/3:
        ans = True
    else:
        ans = False

elif len(a) == 1:
    if a == [0]:
        ans = True
    else:
        ans = False

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

Submission status: Wrong Answer

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

P=[a[0],a[1],a[2]]
P=sorted(P)[::-1]
x,y,z=P[0],P[1],P[2]
flag=False

if a.count(0)==N:
    flag=True
elif N%3==0:
    if a.count(x)==(2*N)//3 and a.count(0)==N//3:
        flag=True
    elif x^y^z==0 and a.count(x)==a.count(y) and a.count(y)==a.count(z):
        flag=True

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

Submission status: Wrong Answer

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

P=[a[0],a[1],a[2]]
P=sorted(P)[::-1]
x,y,z=P[0],P[1],P[2]

flag=False
if x^y^z==0:
    if x==y and y==z and x==0:
        if a.count(0)==N:
            flag=True
    elif x!=0 and y==z and y==0:
        if a.count(x)==2*N/3 and a.count(0)==N/3:
            flag=True
    elif a.count(x)==a.count(y) and a.count(y)==a.count(z):
        flag=True

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

Submission status: Wrong Answer

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

flag=True
for i in range(N):
    if i==0:
        if a[-1]^a[i]^a[i+1]!=0:
            flag=False
            break
    elif i==N-1:
        if a[i-1]^a[i]^a[0]!=0:
            flag=False
            break
    else:
        if a[i-1]^a[i]^a[i+1]!=0:
            flag=False
            break

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

Submission status: Wrong Answer

Solution code:
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

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

if is_match(caps):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if 0 in caps.keys() and len(caps) == 2:
      if caps[0] == N//3:
        return True
    elif len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

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

if is_match(caps):
  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 sum(a)==0:
  print('Yes')
else:
  if n%3!=0:
    print('No')
  else:
    s = len(set(a))
    if s>3:
      print('No')
    else:
      l = Counter(a)
      tf = 1
      if s==3:
        for v in l.values():
          if v!=n//3:
            tf = 0
        li = list(set(a))
        if li[0]^li[1]^li[2]!=0:
          tf = 0
      elif s==2:
        if 0 not in l.keys():
          tf = 0
        else:
          for k in l.keys():
            if k==0 and l[k]!=n//3:
              tf = 0
      print('Yes' if tf else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
if sum(a)==0:
  print('Yes')
else:
  if n%3!=0:
    print('No')
  else:
    s = len(set(a))
    if s>3:
      print('No')
    else:
      l = Counter(a)
      tf = 1
      if s==3:
        for v in l.values():
          if v!=n//3:
            tf = 0
      elif s==2:
        if 0 not in l.keys():
          tf = 0
        else:
          for k in l.keys():
            if k==0 and l[k]!=n//3:
              tf = 0
      else:
        tf = 0
      print('Yes' if tf else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
if sum(a)==0:
  print('Yes')
else:
  if n%3!=0:
    print('No')
  else:
    s = len(set(a))
    if s>3:
      print('No')
    else:
      l = Counter(a)
      tf = 1
      if s==3:
        for v in l.values():
          if v!=n//3:
            tf = 0
      elif s==2:
        if 0 not in l.values():
          tf = 0
        else:
          for k in l.keys():
            if k==0 and l[k]!=n//3:
              tf = 0
      else:
        tf = 0
      print('Yes' if tf else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
if sum(a)==0:
  print('Yes')
else:
  if n%3!=0:
    print('No')
  else:
    s = len(set(a))
    if s>3:
      print('No')
    else:
      l = Counter(a)
      tf = 1
      if s==3:
        for v in l.values():
          if v!=n//3:
            tf = 0
      elif s==2:
        if 0 not in l.values():
          tf = 0
        else:
          for k in l.keys():
            if k==0 and l[k]!=n//3:
              tf = 0
      print('Yes' if tf else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

C=Counter(A)
NUM=[]
if n%3!=0:
    if len(C)!=1 or A[0]!=0:
        print("No");exit()
    else:
        print("Yes");exit()
if all([i%(n//3)==0 for i in C.values()]):
    for i,v in C.items():
        if v==n//3:
            NUM.append(i)
        if v==n*2//3:
            NUM.append(i)
            NUM.append(i)
        if v==n:
            if i==0:print("Yes");exit()
            print("No");exit()
    a,b,c=NUM
    print("Yes" if a^b==c else "No")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

C=Counter(A)
NUM=[]
if n%3!=0: print("No");exit()
if all([i%(n//3)==0 for i in C.values()]):
    for i,v in C.items():
        if v==n//3:
            NUM.append(i)
        if v==n*2//3:
            NUM.append(i)
            NUM.append(i)
        if v==n:
            if i==0:print("Yes");exit()
            print("No");exit()
    a,b,c=NUM
    print("Yes" if a^b==c else "No")

Submission status: Wrong Answer

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

S = 0
 
for a in A:
    S ^= a

print('Yes' if S == 0 else 'No')

Submission status: Wrong Answer

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

p = 0
for a in A:
    p ^= a

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(A)

if len(cnt) == 1:
    if cnt[0] == n:
        print('Yes')
    else:
        print('No')
elif len(cnt) == 2:
    if cnt[0] == n/3:
        print('Yes')
    else:
        print('No')
elif len(cnt) == 3:
    for p in cnt.keys():
        if cnt[p] != n/3:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(A)

if len(cnt) == 1:
    if list(cnt.keys())[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(cnt) == 2:
    t = list(cnt.keys())
    t.sort()
    if t[0] == 0:
        if cnt[0] == n/3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(cnt) == 3:
    for p in cnt.keys():
        if cnt[p] != n/3:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(A)

if len(cnt) == 1:
    if list(cnt.keys())[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(cnt) == 2:
    t = list(cnt.keys())
    t.sort()
    if t[0] == 0:
        if cnt[0] == n/3:
            print('Yes')
        else:
            print('No')
elif len(cnt) == 3:
    for p in cnt.keys():
        if cnt[p] != n/3:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

p = A[0]
for a in A:
    p = p^a
if p == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i in a:
  ans^=i

if ans==0:
  print('Yes')

else:
  print('No')

Submission status: Wrong Answer

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

x=list(set(a))

for i in x:
  if a.count(i)!=n//3:
    print('No')
    exit()
    
if x[0]^x[2]==x[1]:
  print('Yes')
  
else:
  print('No')

Submission status: Wrong Answer

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

x=a+a[:2]
ans=0

for i in range(n):
  ans+=x[i]^x[i+2]
  
if ans==sum(a):
  print('Yes')
  
else:
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(0, n-2):
  if a[i+1]*1000000000 == (a[i] ^ a[i+2])*1000000000:
    cnt += 1

if a[0]*1000000000 == (a[1] ^ a[n-1])*1000000000:
  cnt += 1

if a[n-1]*1000000000 == (a[0] ^ a[n-2])*1000000000:
  cnt += 1

if cnt == n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(0, n-2):
  if a[i+1] == a[i] ^ a[i+2]:
    cnt += 1

if a[0] == a[1] ^ a[n-1]:
  cnt += 1

if a[n-1] == a[0] ^ a[n-2]:
  cnt += 1

if cnt == n:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def main2():
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()

    c = defaultdict(int)
    for a in A:
        c[a] += 1

    if len(c) == 1:
        n = list(c.keys())
        if n[0] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(c) == 2:
        n = list(c.keys())
        if n[0] == 0 and c[n[1]] == 2*c[n[0]]:
            print("Yes")
        else:
            print("No")
    
    else:
        xor = A[0]
        for i in range(1, N):
            xor ^= A[i]

        if xor == 0:
            print("Yes")
        else:
            print("No")
    
if __name__ == "__main__":
    main2()

Submission status: Wrong Answer

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

    e = set(A)
    if len(e) == 1 and 0 not in e:
        print("No")
        exit()

    ans = A[0]
    for i in range(1, N):
        ans ^= A[i]

    if ans == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    e = set(A)

    if len(e) == 1:
        print("No")
        exit()

    ans = A[0]
    for i in range(1, N):
        ans ^= A[i]

    if ans == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    ans = A[0]

    for i in range(1, N):
        ans ^= A[i]

    if ans == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    cnt = collections.Counter(a)
    kind = len(cnt)

    ans = False
    if kind == 1:
        ans |= a[0] == 0
    elif kind == 3:
        key = list(cnt.keys())
        value = list(cnt.values())
        ans = True
        ans &= key[0]^key[1] == key[2]
        ans &= key[1]^key[2] == key[0]
        ans &= key[2]^key[0] == key[1]
        ans &= len(set(value)) == 1
    print("Yes" if ans else "No")
main()

Submission status: Wrong Answer

Solution code:
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


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)


def can_put_on_cap(n):
  global caps

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


# A - XOR Circle
import sys
input = sys.stdin.readline
import copy

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

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

for i in range(N):
  for j in range(i+1, N):
    caps = copy.deepcopy(dic)
    caps[a[i]] -= 1
    caps[a[j]] -= 1
        
    left = a[i]
    mid = a[j]
    count = 2
    
    for k in range(N-2):
      right = get_xor(left, mid)
    
      if can_put_on_cap(right):
        left = mid
        mid = right
        count += 1
      else:
        break
    
    if count == N:
      if mid ^ a[i] == right:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(a)
s = list(set(a))
l = len(s)

if l == 1 and a[0] == 0:
    print('Yes')
elif len(a) % 3 == 0:
    if l == 2 and c[0] == n // 3:
        print('Yes')
    elif l == 3:
        if s[0] ^ s[1] ^ s[2] == 0:
            tmp = c[a[0]]
            if all(x == tmp for x in c.values()):
                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()))

c = Counter(a)
l = len(set(a))

if l == 1 and a[0] == 0:
    print('Yes')
elif len(a) % 3 == 0:
    if l == 2 and c[0] == n // 3:
        print('Yes')
    elif l == 3:
        tmp = c[a[0]]
        if all(x == tmp for x in c.values()):
            print('Yes')
    else:
        print('No')
else:
    print('No')