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:
n=int(input())
A=[int(i) for i in input().split()]
B=[bin(i) for i in A]

if n>=4:
    if sum(A)>0:    
        print("No")
    else:
        print("Yes")
    
else:
    n=0
    for c in B:
        n+=int(c[2:])
    if "3" in str(n):
        print("No")
    elif "1" in str(n):
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
a_lis = [int(_) for _ in input().split()]

def func(x, y):
    if (x == 1 and y == 1) or (x == 0 and y == 0):
        return 0
    elif (x == 0 and y == 1) or (x == 1 and y == 0):
        return 1

def finish(ans, a_lis_item):
    if ans != (a_lis_item % 2):
        print('No')
        sys.exit()

for i, a in enumerate(a_lis):
    if i == 0:
        ans = func(a_lis[N - 1] % 2, a_lis[1] % 2)
    elif i == N - 1:
        ans = func(a_lis[0] % 2, a_lis[N - 2] % 2)
    else:
        ans = func(a_lis[i - 1] % 2, a_lis[i + 1] % 2)
    finish(ans, a_lis[i])

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
# input = sys.stdin.readline
# inf = 10 ** 18
# P = 10 ** 9 + 7

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

if N % 3 > 0:
    if a.count(a[0]) == N:
        print('Yes')
    else:
        print('No')
    sys.exit()

items = []
for ai in a:
    if ai not in items: items.append(ai)
    if len(items) >= 3: break

if len(items) == 1:
    if a.count(items[0]) == N:
        print('Yes')
    else:
        print('No')
elif len(items) == 2:
    cnt = [a.count(item) for item in items]
    if sum(cnt) < N:
        print('No')
    elif 0 not in items:
        print('No')
    elif cnt[0] == cnt[1] * 2 or cnt[0] * 2 == cnt[1]:
        print('Yes')
    else:
        print('No')
else:
    cnt = [a.count(item) for item in items]
    if sum(cnt) < N:
        print('No')
    elif items[2] != items[0] ^ items[1]:
        print('No')
    elif cnt[0] == cnt[1] == cnt[2]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if N == 0:
    print('No')
    sys.exit()
else :
    if a[0] != a[1]^a[len(a)-1]:
        print('No')
        sys.exit()

    for i in range(1,N-2):
        if a[i] != a[i-1]^a[i+1]:
            print('No')
            sys.exit()
            
    if a[len(a)-1] != a[len(a)-2]^a[0]:
        print('No')
        sys.exit()

    print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())

A = list(map(int, input().split()))
if all(a == 0 for a in A):
        print('Yes')
elif N % 3:
    print('No')
else:
    n = N//3
    CA = Counter(A)
    ans = 'Yes'
    t = []
    for k, v in CA.items():
        if not v % n:
            t.append(k)
        
    if len(t) == 3 and (t[0]^t[1] == t[2] and t[2]^t[1] == t[0] and t[0]^t[2] == t[1]):
        ans = 'Yes'
    if len(t) == 2 and (t[0] == 0 or t[1] == 0):
        ans = 'Yes'
    else:
        ans = 'No'
        
    print(ans)

Submission status: Wrong Answer

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

answer = "Yes"
for i in range(N - 1):
  if a[i] != (a[i - 1] ^ a[i + 1]):
    answer = "No"
    
print(answer)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for a in A:
    count[a] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a ^ a == a:
        print('Yes')
        exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[a] == 1 and count[b] == 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

c = collections.Counter(a)
v = list(c.values())
k = list(c.keys())

if len(v) == 3:
  if n % 3 == 0 and v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[0]
y = a[N // 3]
z = a[- N // 3]
if N % 3 != 0:
	print('No')
else:
	if a.count(x) == N // 3 and a.count(y) == N // 3 and a.count(z) == N // 3: 
		if x ^ y == z and y ^ z == x and z ^ x == y:
			print('Yes')
		else:
			print('No')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
import sys, collections
sys.setrecursionlimit(10000000)
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", \
    "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

def solve():
    input = sys.stdin.readline
    mod = 7 + 10 ** 9
    N = int(input())
    A = [int(a) for a in input().split()]
    if len(set(A)) > 3: print("No")
    elif len(set(A)) == 3:
        B = list(set(A))
        count = [0, 0, 0]
        for a in A:
            if a == B[0]: count[0] += 1
            elif a == B[1]: count[1] += 1
            else: count[2] += 1
        if count[0] == count[1] and count[1] == count[2] and B[0] ^ B[1] == B[2]: print("Yes")
        else: print("No")
    elif len(set(A)) == 2:
        if 0 not in A: print("No")
        else:
            A.sort()
            if A[N//2] == 0: print("No")
            elif N % 2 == 1 and N > 3: print("No")
            else: print("Yes")
    else:
        if A[0] == 0: print("Yes")
        else: print("No")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
A = list(map(int,input().split()))
flag = True
#0番目について判定（１とN-1）
if A[0] != A[1]^A[N-1]:
    flag = False
#i番目について判定(0,2 ~ N-3,N-1)
for i in range(1,N-1):
     if A[i] != (A[i-1]^A[i+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()))
b = list(set(a))
flag = False
if len(b) == 3:
    if b[0] ^ b[1] == b[2]:
        flag = True

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

Submission status: Wrong Answer

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

R = {}
for i in a:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

ans = ["Yes", "No"]
if 0 in R:
  if len(R) == 1:
    print(ans[0])
  elif len(R) == 2:
    for i in R.keys():
      if i != 0:
        x = R[i]
      else:
        z = R[i]
    if x == z * 2:
      print(ans[0])
    else:
      print(ans[1])
  else:
    print(ans[1])
else:
  if len(R) != 3:
    print(ans[1])
  else:
    t = -1
    for i in R.values():
      if t == -1:
        t = i
      else:
        if i != t:
          print(ans[1])
          break
    else:
      print(ans[0])

Submission status: Wrong Answer

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

ans = True
for x in range(N-2):
    if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
        print('debug-01')
        ans = False
        break
    if x == N-1-1 and int(bin(a[x]^a[0]), 0) != a[x+1]:
        print('debug-02')
        ans = False
        break
    if x == N-1 and int(bin(a[x]^a[x+1]), 0) != a[0]:
        print('debug-03')
        ans = False
        break
print(ans)

Submission status: Wrong Answer

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


for i in range(N):
    if i == 0:
        B = A[0]
        continue
    else:
        B = B ^ A[i]

if B == 0:
    ans = 'Yes'
else:
    ans = 'No'

if N % 3 != 0:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

a.sort()
if all(a[i] == a[i - 1]^a[(i + 1) % N] for i in range(N)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import permutations

N = int(input())
*A, = map(int, input().split())
A = set(A)
if len(A) == 3:
    for a, b, c in permutations(A, 3):
        if a^c == b and b ^ a == c: print('Yes'); break;
    else: print('No')
else:
    print('No')

Submission status: Wrong Answer

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


if N % 3 == 0:
    if len(set(a)) == 3:
        if a.count(a[0]) == a.count(a[N//3]) == a.count(a[N//3*2]):
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N//3])*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()))

if N%3:
  if all([a==0 for a in A]):
    print('Yes')
  else:
    print('No')

else:
  for i in range(0,3):
    for j in range(0,N//3):
      if A[3*j - i]^A[3*j - i+1]^A[3*j -i + 2] == 0:
        continue
      else:
        print('No')
        exit()
  print('Yes')

Submission status: Wrong Answer

Solution code:
from itertools import permutations
n=int(input())
aa=list(map(int,input().split()))
if 2<n<6:
    for ap in permutations(aa):
        for i in range(n):
            if ap[i-1]!=ap[i-2]^ap[i]:
                break
        else:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
# 一行目の入力
num = int(input())

# 入力された数を分解して保存
input2_a = input().split(" ")

# 入力された数-2回試行する
## コード実行本体

result = "Yes"
for i in range(0, num):
	if (i == 0):
		if (int(input2_a[i]) != (int(input2_a[1]) ^ (int(input2_a[-1])))):
			result = "No"
		continue
	if (i == num - 1):
		if (int(input2_a[i]) != (int(input2_a[0]) ^ (int(input2_a[i - 1])))):
			result = "No"
		continue
	if (int(input2_a[i]) != (int(input2_a[i - 1]) ^ (int(input2_a[i +1])))):
		result = "No"
		continue

print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
l1=l+[l[0]]
l2=[l[1],l[0]]+l[2:]+[l[0]]
flag=0
for i in range(1,n):
  if (l1[i-1]^l1[i+1])!=l1[i]:
    flag=1
    break
if flag==1:
  for i in range(1,n):
    if (l2[i-1]^l2[i+1])!=l2[i]:
      flag=1
      break    
if flag==0:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
a=int(input())
li = list(map(int,input().split()))	
flag = True

if (li[a-1] ^ li[1] != li[0] ):
    flag = False

for i in range(1,a-1):
    if ((li[i-1] ^ li[i+1]) != li[i] ):
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = [int(i) for i in input().split()]
ans = "Yes"
for i in range(len(nums)):
    if i == 0:
        if bin(nums[N-1]^nums[1])==bin(nums[0]):
            continue
        else:
            ans = "No"
    elif i == N-1:
        if bin(nums[N-2]^nums[0])==bin(nums[N-1]):
            continue
        else:
            ans = "No"
    else:
        if bin(nums[i-1]^nums[i+1])==bin(nums[i]):
            continue
        else:
            ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 3 == 0:
    d = {}
    for x in a:
        d.setdefault(x, 0)
        d[x] += 1
    print("Yes" if all([d[x] == n//3 for x in d]) else "No")
else:
    print("Yes" if all([a[i] == a[0] for i in range(n)]) else "No")

Submission status: Wrong Answer

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

def sol() :
    for i in range(N) :  # 先頭
        for j in range(i+1, N) :  # 2頭目
            numbers = [0] * (N + 2)
            numbers[0] = A[i]
            numbers[1] = A[j]
            for k in range(2, N+2) :
                numbers[k] = numbers[k-1] ^ numbers[k-2]

            if numbers[0] == numbers[-2] and numbers[1] == numbers[-1] :
                return numbers[0:N]
    return -1

ans = sol()

if ans == -1 :
    print('No')
else :
    ans.sort()
    A.sort()
    if ans == A :
        print('Yes')
    else :
        print('No')

Submission status: Wrong Answer

Solution code:
def xor_circle(N: int, A: list)->bool:
    M = max(A)

    b = 1
    while b <= M:
        zero, one = 0, 0
        for a in A:
            if a & b:
                one += 1
            else:
                zero += 1

        if one != 2 * zero:
            return False
        b <<= 1

    return True


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    yes = xor_circle(N, A)
    print('Yes' if yes else 'No')

Submission status: Wrong Answer

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

if n >= 4:
    if all(map(lambda x: x == 0, aa)):
        print('Yes')
    else:
        print('No')
else:
    a, b, c = aa
    if a == b ^ c:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    if (a[i%N] ^ a[(i + 2)%N]) == a[(i + 1)%N]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
A=[int(i) for i in input().split()]
AA=collections.Counter(A)
AK=AA.keys()
AV=AA.values()

ans=True
if n%3!=0:
  ans=False
else:
  nn=n//3
  if len(AK)!=3:
    ans=False
  else:
    a,b,c=AK
    if AA[a]!=nn or AA[b]!=nn or AA[c]!=nn:
      ans=False
    else:
      if a^b!=c or b^c!=a:
        ans=False
print("Yes" if ans==True else "No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)

if len(c) == 3 and 0 <= abs(c[0] - c[1]) <= 1 and 0 <= abs(c[0] - c[2]) <= 1 and 0 <= abs(c[1] - c[2]) <= 1 :
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

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

M = {}
for t in a:
  if t not in M:
    M[t] = 0
  M[t] += 1

if N%3!=0:
  if 0 in M and M[0]==N:
    ans = "Yes"
  else:
    ans = "No"
else:
  V = list(M)
  if len(V)==1:
    if 0 in M and M[0]==N:
      ans = "Yes"
    else:
      ans = "No"
  elif len(V)==2:
    a = V[0]
    b = V[1]
    if M[a]*2==M[b]:
      if a^a==b:
        ans = "Yes"
      else:
        ans = "No"
    elif M[b]*2==M[a]:
      if b^b==a:
        ans = "Yes"
      else:
        ans = "No"
    else:
      ans = "No"
  elif len(V)==3:
    a = V[0]
    b = V[1]
    c = V[2]
    if M[a]==M[b]==M[c] and a^b==c:
      ans = "Yes"
    else:
      ans = "No"
  else:
    ans = "No"
print ans

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int, input().split()))
yes = 1

for i in range(n):
  if i == 0:
    if (ai[1] ^ ai[n-1]) != ai[0]:
      yes = 0
  elif i == n-1:
    if (ai[0] ^ ai[n-2]) != ai[n-1]:
      yes = 0
  else:
    if (ai[i-1] ^ ai[i+1]) != ai[i]:
      yes = 0
if yes == 0:
  print('No')
else:
  print('yes')

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ok = False
c = Counter(A)
k = c.keys()
s = len(c.keys())
if len(k) == 3:
    ok = len(Counter(c.values()).keys()) == 1
elif len(k) == 2:
    ok = (min(c.values()) * 2 == max(c.values()) or
          min(c.values()) == max(c.values()))
elif len(k) == 1:
    ok = True
if ok:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

R = {}
for i in a:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

ans = ["Yes", "No"]
if 0 in R:
  if len(R) == 1:
    print(ans[0])
  elif len(R) == 2:
    for i in R.keys():
      if i != 0:
        x = R[i]
      else:
        z = R[i]
    if x == z * 2:
      print(ans[0])
    else:
      print(ans[1])
  else:
    print(ans[1])
else:
  if len(R) != 3:
    print(ans[0])
  else:
    t = -1
    for i in R.values():
      if t == -1:
        t = i
      else:
        if i != t:
          print(ans[1])
          break
    else:
      print(ans[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
data = {}
for a in map(int, input().split()):
	if a in data:
		data[a] += 1
	else:
		data[a] = 1

def pop(data, a):
	if a in data:
		if data[a] == 1:
			del data[a]
		else:
			data[a] -= 1
		return a
	else:
		return None

def check(data):
	a0 = pop(data, list(data.keys())[0])
	a1 = a0
	a2 = pop(data, list(data.keys())[0])
	
	while data:
		a3 = a1 ^ a2
		a4 = pop(data, a3)
		if a4 == None:
			return False
		a1 = a2
		a2 = a3
	return a0 == (a1 ^ a2)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    if N % 3 != 0:
        print("No")
        return
    if 0 in C and len(C) == 2:
        if C[0] * 3 == N:
            print("Yes")
            return
    elif 0 not in C and len(C) == 3:
        ok = True
        for c in C:
            if C[c] * 3 != N:
                print("No")
                return
            X = list(C)
            if X[0] ^ X[1] == X[2]:
                print("Yes")
                return
    print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(j) for j in input().split()]
import collections
c=collections.Counter(a)
l=c.most_common()
p=l[0][1]
q=[]
if len(l)==3:
    for i,j in l:
        if j==p:
            q.append(i)
            continue
        else:
            print("No")
            exit()
else:
    print("No")
    exit()
if q[0]^q[1]==q[2] and q[0]^q[2]==q[1] and q[2]^q[1]==q[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
num_list = [ int(v) for v in input().split() ]
if n == 3 and num_list[0] ^ num_list[1] == num_list[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(N):
    if i == 0:
        B = A[0]
        continue
    else:
        B = B ^ A[i]

if B == 0:
    ans = 'Yes'
else:
    ans = 'No'

if N > 3:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(i) for i in input().split()]
B=[bin(i) for i in A]

if n>=4:
    if sum(A)>0:    
        print("No")
    else:
        print("Yes")
    
else:
    n=0
    for c in B:
        n+=int(c[2:])
    if "3" in str(n):
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

res = 'Yes'

a_dict = dict()

for a in a_list:
    if a not in a_dict.keys():
        a_dict[a] = 1
    else:
        a_dict[a] += 1

a_keys = list(a_dict.keys())
if len(a_keys) != 3:
    res = 'No'
else:
    a, b, c = a_keys
    if a_dict[a] != a_dict[b]:
        res = 'No'
    if a_dict[a] != a_dict[c]:
        res = 'No'
    if a^b != c:
        res = 'No'
    if b^c != a:
        res = 'No'
    if c^a != b:
        res = 'No'

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
num = list(map(int,input().split()))
c = True
nn = num[-1::len(num)]+num+num[0::len(num)]
for i,j in enumerate(nn[1:len(nn)-1]):
  if nn[i] ^ nn[i+2] != nn[i+1]:
    c = False
    break
    
if c:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import itertools


def checkXOR(Cap):
    num = len(Cap)

    for i in range(num):
        L = Cap[(i - 1) % num]
        Me = Cap[i]
        R = Cap[(i + 1) % num]

        if (L ^ R == Me):
            return True

    return False


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


for Cap in itertools.permutations(A):
    SucFlag = False

    if (checkXOR(Cap) == True):
        print("Yes")
        exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    aa = list(map(int, input().split()))

    flg = bin(aa[0]) == bin(aa[len(aa)-1] ^ aa[1]) and bin(aa[len(aa)-1]) == bin(aa[len(aa)-2] ^ aa[0])

    for a1,a2,a3 in zip(aa,aa[1:],aa[2:]):
        if bin(a2) != bin(a1 ^ a3):
            flg = False
            break

    print('Yes' if flg else 'No')
    
resolve()

Submission status: Wrong Answer

Solution code:
from operator import xor

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

D = {}

for n in A :
    if n not in D :
        D[n] = 1
    else :
        D[n] += 1

if N == 3 :
    if xor(A[0], A[1]) == A[2] :
        ans = "Yes"
    else :
        ans = "No"
else :
    if D.get(0,0) >= N :
        ans = "Yes"
    else :
        ans = "No"
print(ans)

Submission status: Wrong Answer

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

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n >= 4 and len(set(a)) == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
n_ls = [int(a) for a in input().split(" ")]
result = 'Yes'
max_len = len(n_ls)
for i in range(0, max_len):
  if i == 0:
    if n_ls[i] != (n_ls[max_len - 1] ^ n_ls[i+1]):
      result = 'No'
      break
  elif i == max_len - 1:
    if n_ls[i] != (n_ls[i-1] ^ n_ls[0]):
      result = 'No'
      break     
  elif n_ls[i] != (n_ls[i-1] ^ n_ls[i+1]):
    result = 'No'
    break

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
def doit(a):
    if len(a) % 3 != 0:
        return "No"
    c = {}
    for ai in a:
        c[ai] = c.get(ai, 0) + 1
    if len(c) > 3:
        return "No"
    k = list(sorted(c.keys()))
    if len(k) == 1:
        if k[0] == 0:
            return "Yes"
    if len(k) == 2:
        if k[0] == 0 and c[k[0]] * 2 == c[k[1]]:
            return "Yes"
    if len(k) == 3:
        if c[k[0]] == c[k[1]] == c[k[2]] and k[0] ^ k[1] == k[2]:
            return "Yes"
    return "No"

print(doit(sorted(a)))

Submission status: Wrong Answer

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

answer = "No"
for i in range(N - 1):
  if a[i] == (a[i - 1] ^ a[i + 1]):
    answer = "Yes"
    
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
aLst = list(map(int, input().split()))
ansB = True
for i in range(N):
    if i == 0:
        if aLst[0] == (aLst[-1] ^ aLst[1]):
            continue
        else:
            ansB = False
            break
    elif i == (N - 1):
        if aLst[i] == (aLst[i - 1] ^ aLst[0]):
            continue
        else:
            ansB = False
    else:
        if aLst[i] == (aLst[i - 1] ^ aLst[i + 1]):
            continue
        else:
            ansB = False

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[int(i) for i in input().split()]
b=list(set(a))
if len(b)==1:
    if b[0]==0:
        print("Yes")
    else:
        print("No")
else:
    if N%3==0 and len(b)==3:
        D={b[0]:0,b[1]:0,b[2]:0}
        for i in range(N):
            D[a[i]]+=1
        if D[b[0]]==D[b[1]] and D[b[1]]==D[b[2]] and b[0]^b[1]==b[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 n % 3 != 0:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")
else:
    count = {}
    for i in range(n):
        count.setdefault(a[i], 0)
        count[a[i]] += 1
    num = list(count.keys())
    if len(num) != 3:
        print("No")
    else:
        if count[num[0]] == count[num[1]] and count[num[1]] == count[num[2]]:
            if num[0]^num[1] == num[2] and num[1]^num[2] == num[0] and num[2]^num[0] == num[1]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

Submission status: Wrong Answer

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

import collections
c = collections.Counter(a)


flag = False
if len(c.keys()) == 3:
    v = []
    for k in c.keys():
        v.append(c[k])

    v.sort()

    if n % 3 == 0:
        if v == [n // 3, n // 3, n // 3]:
            flag = True
    elif n % 3 == 1:
        if v == [n // 3, n // 3, n // 3 + 1]:
            flag = True
    elif n % 3 == 2:
        if v == [n // 3, n // 3 + 1, n // 3 + 1]:
            flag = True

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

Submission status: Wrong Answer

Solution code:
from itertools import permutations

N = int(input())
*A, = map(int, input().split())
if N == 3:
    for a, b, c in permutations(A, 3):
        if a^c == b and b ^ a == c: print('Yes'); break;
    else: print('No')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
l=l+[l[0]]
l2=[l[1],l[0]]+l[2:]
flag=0
for i in range(1,n):
  if (l[i-1]^l[i+1])!=l[i]:
    flag=1
    break
for i in range(1,n):
  if (l2[i-1]^l2[i+1])!=l2[i]:
    flag=1
    break    
if flag==0:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

def solve():
    if N % 3:
        print('No')
    else:
        m = N//3
        cnt = Counter(As)
        vs = []
        for v in cnt.keys():
            if cnt[v] % m:
                print('No')
                return
            vs += [v] * (cnt[v]//m)
#        print(vs)
        A, B, C = vs
#        print(A, B, C)
        if A^B^C:
            print('No')
        else:
            print('Yes')

solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())

A = list(map(int, input().split()))
if all(a == 0 for a in A):
        print('Yes')
elif N % 3:
    print('No')
else:
    n = N//3
    CA = Counter(A)
    ans = 'Yes'
    t = []
    for k, v in CA.items():
        if v != n:
            ans = 'No'
        t.append(k)
        
    if len(t) == 3 and (t[0]^t[1] == t[2] and t[2]^t[1] == t[0] and t[0]^t[2] == t[1]):
        pass
    else:
        ans = 'No'
        
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N= int(input())

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

x = Counter(a)

ok = False
if len(x) == 3:
    for i in a:
        if x[i] != len(x) // 3:
            break
    else:
        ok = True
elif len(x) == 1:
    if x.get(0) is not None:
        ok = True

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

Submission status: Wrong Answer

Solution code:
import sys, collections
sys.setrecursionlimit(10000000)
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", \
    "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

def solve():
    input = sys.stdin.readline
    mod = 7 + 10 ** 9
    N = int(input())
    A = [int(a) for a in input().split()]
    if len(set(A)) > 3: print("No")
    elif len(set(A)) == 3:
        B = list(set(A))
        count = [0, 0, 0]
        for a in A:
            if a == B[0]: count[0] += 1
            elif a == B[1]: count[1] += 1
            else: count[2] += 1
        if count[0] == count[1] and count[1] == count[2] and B[0] ^ B[1] == B[2]: print("Yes")
        else: print("No")
    elif len(set(A)) == 2:
        if 0 not in A: print("No")
        else:
            A.sort()
            if A[N//2] > 0 and N % 2 == 0: print("Yes")
            else: print("No")
    else:
        if A[0] == 0: print("Yes")
        else: print("No")

    return 0

if __name__ == "__main__":
    solve()