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:
# 19
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()
# 全部 0 なら Yes
if sum(a) == 0:
    print('Yes')
    exit()
sum_xor = 0
for elem in a:
    sum_xor ^= elem
if sum_xor == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# 19
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()
sum_xor = 0
for elem in a:
    sum_xor ^= elem
if sum_xor == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
  print("Yes")
else:
  t=list(set(a))
  if len(t)==3 and n%3==0:
    if t[0]^t[1]==t[2] and a.count(t[0])==n//3 and a.count(t[1])==n//3:
      print("Yes")
    elif min(t)==0 and (a.count(0)==n//3 or a.count(0)==n//3*2):
      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")
else:
  t=list(set(a))
  if len(t)==3 and n%3==0:
    if t[0]^t[1]==t[2] and a.count(t[0])==n//3 and a.count(t[1])==n//3:
      print("Yes")
    elif min(t)==0 and (a.count(0)==n//3 or a.count(t[1])==n//3*2):
      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")
else:
  t=list(set(a))
  if len(t)==3 and n%3==0:
    if t[0]^t[1]==t[2] and a.count(t[0])==n//3 and a.count(t[1])==n//3:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A_LIST = list(map(int, input().split()))
A_SET = set(A_LIST)
if len(A_SET) == 1:
    if sum(A_SET) == 0:
        print('Yes')
    else:
        print('No')
elif len(A_SET) == 2:
    a1, a2 = sorted(A_SET)
    if a1 == 0 and A_LIST.count(a1) == 2 * N // 3 and A_LIST.count(a2) == N // 3:
        print('Yes')
    else:
        print('No')
elif len(A_SET) == 3:
    a1, a2, a3 = A_SET
    if a1 ^ a2 == a3 and A_LIST.count(a1) ==  A_LIST.count(a2) and A_LIST.count(a2) == A_LIST.count(a3):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A_LIST = list(map(int, input().split()))
A_SET = set(A_LIST)
if len(A_SET) == 1:
    if sum(A_SET) == 0:
        print('Yes')
    else:
        print('No')
elif len(A_SET) == 1:
    a1, a2 = sorted(A_SET)
    if a1 == 0 and A_LIST.count(a1) == 2 * N // 3 and A_LIST.count(a2) == N // 3:
        print('Yes')
    else:
        print('No')
elif len(A_SET) == 3:
    a1, a2, a3 = sorted(A_SET)
    if a1 ^ a2 ^ a3 == 0 and A_LIST.count(a1) == N // 3 and A_LIST.count(a2) == N // 3 and A_LIST.count(a3) == 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()))
s = set(a)
l = len(s)
if l == 1:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")
elif l == 2:
    x, y = min(a), max(a)
    if x == 0 and a.count(0) == n / 3:
        print("Yes")
    else:
        print("No")
elif l == 3:
    x, y, z = s
    if x ^ y ^ z == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b=int(input()),list(map(int, input().split())),0
for i in a:b^=i
print("YNeos"[b!=0::2])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[6]:


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


# In[7]:


if sum(a) == 0:
    print("Yes")
else:
    if N%3 == 0:
        a0 = a[0]
        for i in range(1,N):
            a0 ^= a[i]
        if a0 == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


# In[ ]:

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
c = Counter(A)

a = list(c.keys())
n = len(a)

if N%3 == 0:
	if n == 3 and len(set(c.values())) == 1 and a[0]^a[1] == a[2]:
		print("Yes")
	elif n == 2 and c[0] == N//3:
		print("Yes")
	else:
		print("No")
elif n == 1 and c[0] == N:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
c = Counter(A)

a = list(c.keys())
n = len(a)

if N%3 == 0:
	if n == 3 and len(set(c.values())) == 1 and a[0]^a[1] == a[2]:
		print("Yes")
	elif n == 2 and c[0] == N//3:
		print("Yes")
elif n == 1 and c[0] == N:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
c = Counter(A)
n = len(c.values())

if N%3 == 0:
	if n == 3 and len(set(c.values())) == 1:
		print("Yes")
	elif n == 2 and c[0] == N//3:
		print("Yes")

elif c[0] == N:
	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 range(N):
  ans^=a[i]
if ans!=0:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
dp=[]
bp=[]
ans=a[0]^a[2]
for i in range(1,N+1,2):
  if i==1:
    dp.append(ans)
    continue
  ans=(ans^a[i-3])^a[(i+1)%N]
  dp.append(ans)
ans=a[1]^a[-1]
for i in range(0,N+1,2):
  if i==0:
    bp.append(ans)
    continue
  ans=(ans^a[i-3])^a[(i+1)%N]
  bp.append(ans)
for i in range(N):
  if i%2==0:
    if a[i]!=bp[i//2]:
      print('No')
      exit()
  else:
    if a[i]!=dp[i//2]:
      print('No')
      exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
dp=[]
bp=[]
ans=a[0]^a[2]
for i in range(2,N+1,2):
  if i==2:
    dp.append(ans)
    continue
  ans=(ans^a[i-4])^a[i%N]
  dp.append(ans)
ans=a[1]^a[-1]
for i in range(1,N+1,2):
  if i==1:
    bp.append(ans)
    continue
  ans=(ans^a[i-4])^a[i%N]
  bp.append(ans)
for i in range(N):
  if i%2==0:
    if a[i]!=bp[i//2]:
      print('No')
      exit()
  else:
    if a[i]!=dp[i//2]:
      print('No')
      exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    if a.count(0) == n:
        print("Yes")
    else:
        if n % 3 == 0:
            s = list(set(a))
            if len(s) == 3:
                if s[0] ^ s[2] == s[1] and s[1] ^ s[0] == s[2] and s[2] ^ s[1] == s[0]:
                    if a.count(s[0]) == a.count(s[1]) == a.count(s[2]):
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
            elif len(s) == 2:
                if a.count(0) == n // 3 * 2:
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    if a.count(0) == n:
        print("Yes")
    else:
        if n % 3 == 0:
            s = list(set(a))
            if len(s) == 3:
                if s[0] ^ s[2] == s[1] and s[1] ^ s[0] == s[2] and s[2] ^ s[1] == s[0]:
                    if a.count(s[0]) == a.count(s[1]) == a.count(s[2]):
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    if n % 3 == 0:
        from collections import Counter
        s = list(set(a))
        if len(s) == 3:
            if s[0] ^ s[2] == s[1] and s[1] ^ s[0] == s[2] and s[2] ^ s[1] == s[0]:
                if a.count(s[0]) == a.count(s[1]) == a.count(s[2]):
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

#%%
setA = set(A)
if len(setA) == 1:
    if sum(A) == 0:
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 2:
    a1, a2 = sorted(setA)
    print(a1, a2)
    if (a1 == 0) and (A.count(a1) * 3 == n):
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 3:
    a1, a2, a3 = setA
    if (a1 ^ a2 ^ a3 == 0) and (A.count(a1) == A.count(a2) == A.count(a3)):
        ans = 'Yes'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

#%%
setA = set(A)
if len(setA) == 1:
    if A[0] == 0:
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 2:
    a1, a2 = sorted(setA)
    if (a1 == 0) and (A.count(a1) * 3 == n):
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 3:
    a1, a2, a3 = setA
    if (a1 ^ a2 ^ a3 == 0) and (A.count(a1) == A.count(a2) == A.count(a3)):
        ans = 'Yes'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

#%%
# 直感的にはすべてのXORが0になればよい→嘘解法
ans = 0
for a in A:
    ans = ans ^ a

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

Submission status: Wrong Answer

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

#%%
# 直感的にはすべてのXORが0になればよい
ans = A[0]
for a in A[1:]:
    ans = ans ^ a

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
u = list(set(l))
if len(u)==1 and u[0]==0:
  print("Yes")
elif n%3==0:
  if len(u)==2:
    x = l.count(u[0])
    y = l.count(u[1])
    if (x==2*n/3 and y==n/3) or (y==2*n/3 and x==n/3):
      print("Yes")
    else:
      print("No")
  elif len(u)==3:
    x = l.count(u[0])
    y = l.count(u[1])
    z = l.count(u[2])
    if x==n/3 and y==n/3 and z==n/3:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
pre = 0
for num in a:
    pre = pre^num
if pre == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
pre = 0
for num in a:
    pre = pre^num
if pre == 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 A.count(0) == N:
    print("Yes")
    exit()

d = Counter(A)
if len(d.keys()) > 3:
    print("No")
    exit()
elif len(d.keys()) == 3:
    a, b, c = d.keys()
    if d[a] == d[b] == d[c]:
        print("Yes")
    elif a ^ b ^ c == 0:
        print("Yes")
    else:
        print("No")
    exit()
elif len(d.keys()) == 2:
    a, b = d.keys()
    if a * b != 0:
        print("No")
    else:
        if a != 0:
            d[a], d[b] = d[b], d[a]  # aを0にする
        if d[a] * 3 == N and 3 * d[b] == 2 * N:
            print("Yes")
        else:
            print("No")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if A.count(0) == N:
    print("Yes")
    exit()

d = Counter(A)
if len(d.keys()) > 3:
    print("No")
    exit()
elif len(d.keys()) == 3:
    a, b, c = d.values()
    if a == b == c and a ^ b ^ c == 0:
        print("Yes")
    else:
        print("No")
    exit()
elif len(d.keys()) == 2:
    a, b = d.keys()
    if a * b != 0:
        print("No")
    else:
        if a != 0:
            d[a], d[b] = d[b], d[a]  # aを0にする
        if d[a] * 3 == N and 3 * d[b] == 2 * N:
            print("Yes")
        else:
            print("No")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if A.count(0) == N:
    print("Yes")
    exit()

d = Counter(A)
if len(d.keys()) > 3:
    print("No")
    exit()
elif len(d.keys()) == 3:
    a, b, c = d.values()
    if a == b == c:
        print("Yes")
    else:
        print("No")
    exit()
elif len(d.keys()) == 2:
    a, b = d.keys()
    if a * b != 0:
        print("No")
    else:
        if a != 0:
            d[a], d[b] = d[b], d[a]  # aを0にする
        if d[a] * 3 == N and 3 * d[b] == 2 * N:
            print("Yes")
        else:
            print("No")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if A.count(0) == N:
    print("Yes")
    exit()

d = Counter(A)
if len(d.keys()) > 3:
    print("No")
    exit()
elif len(d.keys()) == 3:
    a, b, c = d.values()
    if a == b == c:
        print("Yes")
    else:
        print("No")
    exit()
elif len(d.keys()) == 2:
    a, b = d.values()
    if a * b != 0:
        print("No")
    else:
        if a != 0:
            a, b = b, a  # aを0にする
        if a * 3 == N and 3 * b == 2 * N:
            print("Yes")
        else:
            print("No")
    exit()
print("No")

Submission status: Wrong Answer

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

xor = 0
for i in range(N):
    xor ^= A[i]

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

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    As = [int(item) for item in input().split()]
    As.sort()
    temp_set = set(As)
    is_true = True
    if len(temp_set) == 1:
        if As[0] != 0:
            is_true = False
    elif len(temp_set) == 2:
        x_num = As.count(max(As))
        zero_num = As.count(0)
        if x_num != 2*zero_num:
            is_true = False

    elif len(temp_set) == 3:
        temp_cnt = collections.Counter(As)
        temp_set = list(set(As))
        if temp_cnt[temp_set[0]] == temp_cnt[temp_set[1]] == temp_cnt[temp_set[2]]:
            is_true = True
        else:
            is_true = False
        
    else:
        is_true = False

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    As = [int(item) for item in input().split()] 
    temp_set = set(As)
    is_true = True
    if len(temp_set) == 1:
        if As[0] != 0:
            is_true = False
    elif len(temp_set) == 2:
        x_num = As.count(max(As))
        zero_num = As.count(min(As))
        if x_num != 2*zero_num:
            is_true = False
    elif len(As) == 3:
        temp_cnt = collections.Counter(As)
        temp_set = list(set(As))
        if temp_cnt[temp_set[0]] == temp_cnt[temp_set[1]] == temp_cnt[temp_set[2]]:
            is_true = True
        else:
            is_true = False
        
    else:
        is_true = False

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    As = [int(item) for item in input().split()] 
    temp_set = set(As)
    is_true = True
    if len(temp_set) == 1:
        if As[0] != 0:
            is_true = False
    elif len(temp_set) == 2:
        x_num = As.count(max(As))
        zero_num = As.count(0)
        if x_num != 2*zero_num:
            is_true = False
    elif len(As) == 3:
        temp_cnt = collections.Counter(As)
        temp_set = list(set(As))
        if temp_cnt[temp_set[0]] == temp_cnt[temp_set[1]] == temp_cnt[temp_set[2]]:
            is_true = True
        else:
            is_true = False
        
    else:
        is_true = False

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()] 
    temp_set = set(As)
    is_true = True
    if len(temp_set) == 1:
        if As[0] != 0:
            is_true = False
    elif len(temp_set) == 2:
        x_num = As.count(max(As))
        zero_num = As.count(0)
        if x_num != 2*zero_num:
            is_true = False
    elif len(As) == 3:
        for i in range(N):
            if As[i -1] ^ As[(i+1)%N] ^ As[i] != 0:
                is_true = False
                break
    else:
        is_true = False

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()] 
    temp_set = set(As)
    is_true = True
    if len(temp_set) == 1:
        if As[0] != 0:
            is_true = False
    elif len(temp_set) == 2:
        x_num = As.count(max(As))
        zero_num = As.count(0)
        if x_num != 2*zero_num:
            is_true = False
    else:
        for i in range(N):
            if As[i -1] ^ As[(i+1)%N] ^ As[i] != 0:
                is_true = False
                break

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()] 

    is_true = True
    for i in range(N):
        if As[i -1] ^ As[(i+1)%N] ^ As[i] != 0:
            is_true = False
        

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()] 

    is_true = True
    for i in range(N):
        if bin(As[i -1] ^ As[(i+1)%N]) != bin(As[i]):
            is_true = False

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()] 

    is_true = True
    for i in range(N):
        if As[i -1] ^ As[(i+1)%N] != As[i]:
            is_true = False

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



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

flag = True
for i in range(1, N-1):
  if a[i-1]^a[i+1] != a[i]:
    flag = False
    break
    
if flag:
  if a[1]^a[-1] != a[0]:
    flag = False
  if a[0]^a[-2] != a[-1]:
    flag = False
    
if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

t = A[0]
for i in range(1, N):
    t ^= A[i]
print('Yes' if t == 0 else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if 0 in a:
  if a.count(0)==len(a) or a.count(0)==len(a)//3:
    print('Yes')
  else:print('No')
sm=a[0]
for i in a[1:]:
  sm=sm^i
print(['Yes','No'][sm>0])

Submission status: Wrong Answer

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