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())
r = list(map(int,input().rstrip().split(' ')))
if (r[1] ^ r[N-1]) != r[0]:
    f = 0
else:
    f = 1
for i in range(1,N-1):
    if (r[i-1] ^ r[i+1]) != r[i]:
        f = 0
        break
if (r[0] ^ r[N-2]) != r[N-1]:
    flag = 0
if f == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

def f(a, b, c):
    if a ^ b == c and a ^ c == b and b ^ c == a:
        return True
    else:
        return False

if N % 3 != 0:
    x = a[0]
    for i in range(len(a)):
        if a[i] != x:
            print("No")
            exit()
    if f(x, x, x):
        print("Yes")
    else:
        print("No")

else:
    flag = 0
    x = [-1, -1, -1]
    for i in range(len(a)):
        if a[i] not in x:
            if flag == 3:
                print("No")
                exit()

            x[flag] = a[i]
            flag += 1

    if flag == 3:
        if f(x[0], x[1], x[2]):
            print("Yes")
        else:
            print("No")
    elif flag == 1:
        if f(x[0], x[0], x[0]):
            print("Yes")
        else:
            print("No")
    else:
        if f(x[0], x[0], x[1]) or f(x[0], x[1], x[1]):
            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 nums[N-1]^nums[1]==nums[0]:
            continue
        else:
            ans = "No"
    elif i == N-1:
        if nums[N-2]^nums[0]==nums[N-1]:
            continue
        else:
            ans = "No"
    else:
        if nums[i-1]^nums[i+1]==nums[i]:
            continue
        else:
            ans = "No"

print(ans)

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
items.sort()

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')
    if items[0] > 0:
        print('No')
    elif a.count(items[1]) == a.count(0) * 2:
        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:
N=int(input())
A=list(map(int,input().split()))
SA=set(A)
if len(SA)==1 and A[0]==0:
    print('Yes')
elif N%3==0:
    if len(SA)==3:
        x=[0,0,0]
        y=[0,0,0]
        for i,a in enumerate(SA):
            x[i]=A.count(a)
            y[i]=a
        if x[0]==x[1] and x[1]==x[2]:
            if y[0]^y[1]==y[2] and y[1]^y[2]==y[0] and y[2]^y[0]==y[1]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    elif len(SA)==2:
        x=[0,0]
        y=[0,0]
        for i,a in enumerate(SA):
            x[i]=A.count(a)
            y[i]=a
        if x[0]*2==x[1]:
            if y[1]==0:
                print('Yes')
            else:
                print('No')
        elif x[1]*2==x[0]:
            if y[0]==0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
else:
    print('No')

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
            breakAC
    else:
        if aLst[i] == (aLst[i - 1] ^ aLst[i + 1]):
            continue
        else:
            ansB = False
            break

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

a = sorted(a_b)

ans = 0
for i in range(1,N-1):
    if((a[i-1] ^ a[i+1]) == a[i]):
        ans +=1


if((a[N-1] ^ a[1]) == a[0]):
    ans +=1

if((a[N-2] ^ a[0]) == a[N-1]):
    ans +=1


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

Submission status: Wrong Answer

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

import collections
c = collections.Counter(a)

v = []
for k in c.keys():
    v.append(c[k])
v.sort()

flag = False
if n % 3 == 0:
    if v == [n // 3, n // 3, n // 3]:
        flag = True
else:
    if v == [n]:
        flag = True

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
setA = list(set(A))
if len(setA) == 0 and setA[0] == 0:
	print("Yes")
	exit()
if N % 3 != 0:
	print("No")
	exit()
if len(setA) == 1 or len(setA) > 3:
	print("No")
	exit()
if len(setA) == 2:
	if 0 in setA:
		setA.sort()
		if A.count(0) == N // 3 and A.count(setA[1]) == (N // 3) * 2:
			print("Yes")
			exit()
	print("No")
	exit()

if setA[0] ^ setA[1] != setA[2]:
	print("No")
	exit()
for a in setA:
	if A.count(a) != N // 3:
		print("No")
		exit()
print("Yes")
exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from sys import stdin

def main():
    N = int(input())
    A = sorted(map(int, input().split()))

    a = deque(A)
    for _ in range(N):
        if a[0] ^ a[2] == a[1]:
            a.rotate()
        else:
            print('No')
            break
    else:
        print('Yes')

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a_lists = list(input().split())

for i in range(int(n)):
    if i == 0:
        if int(a_lists[i]) != int(a_lists[i+1]) ^ int(a_lists[n-1]):
            print("No")
            exit()
    elif i == n-1:
        if int(a_lists[i]) != int(a_lists[i-1]) ^ int(a_lists[0]):
            print("No")
            exit()
    else:
        if int(a_lists[i]) != int(a_lists[i+1]) ^ int(a_lists[i-1]):
            print("No")
            exit()

print("Yes")

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]):
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 1:
        if a[0] == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

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()
ll=[]
for i,j in l:
    ll.append(i)
if 0 in ll:
    if len(l)==2:
        for i,j in l:
            if i==0:
                z=j
            else:
                t=j
        if 2*z==t:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()

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:
a = int(input())
b = list(map(int, input().split()))
d = [0] * 32
for i in range(3):
    e = bin(b[i])[2:]
    for j in range(len(e)):
        d[j] += int(e[-j-1])
for i in range(len(d)):
    if d[i] % 2 != 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

a = a + a[:2]

for i in range(N):
	if not a[i] ^ a[i+1] == a[i+2]:
		print("No")
		exit()

print("Yes")

Submission status: Wrong Answer

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

ans = False
x = a[0]
y = a[1]
available = list(a[2:])
while available:
    r = x ^ y
    if r in available:
        available.remove(r)
        x = y
        y = r
    else:
        break
if not available:
    ans = x ^ y == a[0]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(a, b, c):
    if a ^ b == c and a ^ c == b and b ^ c == a:
        return True
    else:
        return False

if N % 3 != 0:
    x = a[0]
    for i in range(len(a)):
        if a[i] != x:
            print("No")
            exit()
    if f(x, x, x):
        print("Yes")
    else:
        print("No")

else:
    flag = 0
    x = [-1, -1, -1]
    for i in range(len(a)):
        if a[i] not in x:
            if flag == 3:
                print("No")
                exit()

            x[flag] = a[i]
            flag += 1

    if flag == 3:
        if f(x[0], x[1], x[2]):
            print("Yes")
        else:
            print("Now")
    elif flag == 1:
        if f(x[0], x[0], x[0]):
            print("Yes")
        else:
            print("No")
    else:
        if f(x[0], x[0], x[1]) or f(x[0], x[1], x[1]):
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

k, v = list(Counter(a).keys()), list(Counter(a).values())
if len(k) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2] :
    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')
elif len(a)<=2:
    if 0 in a:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

ans = 'Yes'
for x in range(N-2):
    if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
        ans = 'No'
        break
    if x == N-1-1 and int(bin(a[x]^a[0]), 0) != a[x+1]:
        ans = 'No'
        break
    if x == N-1 and int(bin(a[x]^a[1]), 0) != a[0]:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=sorted(acinput())
a.extend(a[:2])
res="Yes"
for i in range(N):
    if a[i]!=a[i+1]^a[i+2]:
        res="No"
        break

print(res)

Submission status: Wrong Answer

Solution code:
import itertools

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

for s in list(itertools.permutations(l)):
    for i in range(n):
        if [l[(i-1)%n]^l[(i+1)%n] for i in range(n)]==l:
            print('YES')
            exit()
        else:pass
print('NO')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=set(a)
l=len(b)
if l==2:
  c=sorted([b.pop(),b.pop()])
  if c[1]^c[0]==c[1]:
    if n%2==0 and a[n//2-1]!=a[n//2]:print("Yes")
    else:print("No")
  else:print("No")
  exit()
elif l==1:
  if a[0]==0:print("Yes")
  else:print("No")
  exit()
elif l!=3:print("No");exit()
if n%3!=0:print("No");exit()
if b.pop()^b.pop()^b.pop()!=0:print("No");exit()
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:
N = int(input())
A = list(map(int, input().split()))

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


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

if N % 3 != 0 or len(k) != 3:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def logic():
    N = int(input())
    alpha = list(map(int, input().split()))
    i = 0
    check = True
    while i < N:
      if i == 0:
        if not (alpha[N-1]^alpha[i+1]) == alpha[i]:
          check = False
          break
      elif i == N-1:
        if not (alpha[i-1]^alpha[0]) == alpha[i]:
          check = False
          break
      else :
        if not (alpha[i-1]^alpha[i+1]) == alpha[i]:
          check = False
          break
      i += 1
    if check:
      print("Yes")
    else:
      print("No")

if __name__ == '__main__':
    logic()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

prev = a[1]
diff = a.pop(0) - a.pop(0)
flag = True
for x in a:
    if prev - x != diff:
        flag = False
        break
    prev = x

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

Submission status: Wrong Answer

Solution code:
import itertools

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

def check(x):
  print(x)
  res = True
  for i in range(len(x)):
    _prev = i-1 if i>0 else len(x)-1
    _next = i+1 if i<len(x)-1 else 0
    res &= x[_prev]^x[_next] == x[i]
  return res

for e in itertools.permutations(a[1:]):
  if check(list(e)+[a[0]]):
    print('Yes')
    break
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    c = Counter(A)
    if 0 in c and len(c) == 1:
        return 'Yes'

    if 0 in c and len(c) == 2:
        v0 = c[0]
        for k, v in c.items():
            if k != 0 and v == 2 * v0:
                return 'Yes'

    if len(c) == 3:
        vals = set()
        for v in c.values():
            vals.add(v)

        if len(vals) == 1:
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
from collections import Counter

# s = input()
N = int(input())
A = list(map(int, input().split()))
# a, b = map(int, input().split())

c = Counter()

for a in A:
    c[a] += 1

if len(c.keys()) == 1:
    print("Yes")
    exit()

v = list(c.values())
if len(v) == 3:
    if v[0] == v[1] and v[1] == v[2]:
        print("Yes")
        exit()

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 x == 0 and a[-1] == 0:
	print('Yes')
else:
	if N % 3 == 0:
		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')
	else:
		print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a.sort()

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:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
A=np.array(a)
cut=0
for i in range (n):
    if A[i]%2==1:
        cut=cut+1
if cut%2==0:
    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:
        for c in C:
            if C[c] * 3 != N:
                print("No")
                return
            X = list(C)
            if X[0] ^ X[1] != X[2]:
                print("No")
                return
            print("Yes")
            return
    elif len(C) == 1 and 0 in C:
        print("Yes")
        return
    print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
if N!=3:
  print("No")
  exit()
a,b,c=map(int,input().split())
if a ^ b== c and a ^ c == b:
  print("Yes")
else:
  print("No")

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) == 0 for x in d]) else "No")
else:
    print("Yes" if all([x == a[0] for x in a]) else "No")

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    a_list.extend([a_list[0], a_list[-1]])
    for i in range(n):
        if a_list[i] != a_list[i - 1] ^ a_list[i + 1]:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = [b == a ^ c for a, b, c in zip([a[-1]] + a[:-1], a, a[1:] + [a[0]])]
ans += [b == c ^ a for a, b, c in zip([a[-1]] + a[:-1], a, a[1:] + [a[0]])]
if all(ans):
    print("Yes")
else:
    print("No")

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:
        w = 0
        for j in x:
            w ^= j
        if w == 0:
            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:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
if n%3!=0:
  print("No")
  exit()
elif len(b)==2:
  b = sorted(list(b))
  if b[0]==0 and a.count(0)==n//3 and a.count(b[1])==(n//3)*2:
    print("Yes")
    exit()
elif len(b)==3:
  b = sorted(list(b))
  p, q, r = b[0], b[1], b[2]
  if p^q==r or q^r==p or r^p==q:
    if a.count(b[0])==n//3 and a.count(b[1])==n//3 and a.count(b[2])==n//3:
      print("Yes")
      exit()
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)
length = len(cnt)
if length == 1:
    if cnt[0] == 0:
        print("No")
    else:
        print("Yes")
elif length == 2:
    if cnt[0] == n // 2 and n % 2 == 0:
        print("Yes")
    else:
        print("No")
elif length == 3:
    val = []
    for key in cnt.keys():
        val.append(key)
    if (val[0] ^ val[1] != val[2]) or (val[1] ^ val[2] != val[0]) or (val[2] ^ val[0] != val[1]):
        print("No")
        exit()
    if n % 3 != 0:
        print("No")
        exit()
    if (cnt[val[0]] != n // 3) or (cnt[val[1]] != n // 3) or (cnt[val[2]] != n // 3):
        print("No")
        exit()
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

prev = a[1]
diff = a.pop(0) - a.pop(0)
flag = True
for x in a:
    if prev - x != diff:
        flag = False
        break
    prev = x

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

Submission status: Wrong Answer

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

a.append(a[0])
a.append(a[1])

for i in range(n):
    if (a[i] ^ a[i+1]) != a[i+2]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = list(Counter(a).values())
if len(c) == 3 and c[0] == c[1] == c[2] :
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')



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

if all((i == 0) for i in a):
    print('Yes')
    exit()

p = n // 3
if n % 3 != 0:
    print('No')
    exit()

if 0 in a:
    a = sorted(a)
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    g = gb(a)
    for k, v in g:
        if k == 0:
            continue
        if len(list(v)) % 2 != 0:
            print('No')
            exit()
    print('Yes')
    exit()
    # if a[p] != a[-1]:
    #     print('No')
    #     exit()
    # print('Yes')
    # exit()

a = sorted(a)
if a.count(a[0]) != p or a.count(a[p]) != p or a.count(a[-1]) != p:
    print('No')
else:
    if a[0] == a[p] or a[p] == a[-1] or a[-1] == a[0]:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:


n = int(input())
ans = "No"
num_list = [ int(v) for v in input().split() ]

if n % 3 == 0 and num_list[0] ^ num_list[1] == num_list[2]:
    m = n // 3
    if num_list == [num_list[0], num_list[1], num_list[2]] * m:
        ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
print("Yes"if len(b)==3 and len(list(set([a.count(i)for i in b])))==1else"No")

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import defaultdict

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    A = defaultdict(lambda : 0)
    for x in a:
        A[x] += 1
    if len(A) == 1 and 0 in a:
        print(YES)
        return
    if N % 3 > 0:
        print(NO)
        return
    if len(A) != 3:
        print(NO)
        return
    L = list(A.keys())
    if L[0] ^ L[1] != L[2]:
        print(NO)
        return
    if A[L[0]] == A[L[1]] and A[L[0]] == A[L[2]]:
        print(YES)
        return
    print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

B = set(A)
if N%3 == 0 and len(B) == 3:
    C = list(B)
    ans = C[0]
    for i in range(1,3):
        ans = ans^C[i]

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

print('No')

Submission status: Wrong Answer

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

k = 0
g = 0

for i in range(N):
    if A[i] % 2 == 0:
        g += 1
    else:
        k += 1

if k == 0 or (g != 0 and k % g == 0 and k / g == 2):
    print('Yes')
else:
    print('No')

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 A[N-1] != (A[N-2]^A[0]):
    flag = False

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

Submission status: Wrong Answer

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

flag = True

for i in range(n):
    if line[i] != line[(i-1)%n] ^ line[(i+1)%n]:
        flag = False

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

Submission status: Wrong Answer

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

a = a + [a[0]]

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

print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
cnt = Counter(l)
res = False
if n == 3:
    res = l[0] ^ l[1] == l[-1]
elif len(cnt) == 1: res = True
elif (n & 1) and len(cnt) == 2:
    res = cnt[l[0]] in (n // 2, n // 2 + 1)
print("Yes" if res else "No")

Submission status: Wrong Answer

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

for i in range(n-1):
  if an[i] != (an[i-1] ^ an[i+1]):
    print('No')
    exit()
if an[n-1] == (an[n-2] ^ an[0]):
  print('Yes')

Submission status: Wrong Answer

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

ans = 'Yes'
for x in range(N-2):
    if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
        ans = 'No'
        break
    if x == N-1-1 and int(bin(a[x]^a[0]), 0) != a[x+1]:
        ans = 'No'
        break
    if x == N-1 and int(bin(a[x]^a[x+1]), 0) != a[0]:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
flag = True
if(a[n-1]^a[1] != a[0]):
    flag = False
if(a[n-2]^a[0] != a[n-1]):
    flag = False

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

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

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[1]]
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:
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    c = Counter(A)
    if 0 in c and len(c) == 2:
        v0 = c[0]
        for k, v in c.items():
            if k != 0 and v == 2 * v0:
                return 'Yes'

    if len(c) == 3:
        vals = set()
        for v in c.values():
            vals.add(v)

        if len(vals) == 1:
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
from collections import Counter

# s = input()
N = int(input())
A = list(map(int, input().split()))
# a, b = map(int, input().split())

c = Counter()

for a in A:
    c[a] += 1

if N%3 != 0:
    if len(c.keys()) == 1:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

v = list(c.values())
if len(v) == 3:
    if v[0] == v[1] and v[1] == v[2]:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
setA = list(set(A))
if len(setA) == 0 and setA[0] == 0:
	print("Yes")
	exit()
if N % 3 != 0:
	print("No")
	exit()
if len(setA) != 3:
	print("No")
	exit()
if setA[0] ^ setA[1] != setA[2]:
	print("No")
	exit()
for a in setA:
	if A.count(a) != N // 3:
		print("No")
		exit()
print("Yes")
exit()

Submission status: Wrong Answer

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

count = 0
for i in range(len(a)):
    if i == 0:
        left = -1
        right = i + 1
    elif i == len(a) - 1:
        left = i - 1
        right = 0
    else:
        left = i - 1
        right = i + 1

    number = bin(a[left] ^ a[right])
    if bin(a[i]) != number:
        print('No')
        break
    else:
        count += 1

if count == len(a):
    print('Yes')

Submission status: Wrong Answer

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

ans = 'Yes'

for i in range(n-1):
    # print(a[i-1],a[i],a[i+1])
    if bin(a[i]) == bin(a[i-1] ^ a[i+1]):
        pass
    else:
        ans = 'No'
        break

# if ans == 'Yes':
#     print(a[n-2],a[n-1],a[0])
if bin(a[n-1]) == bin(a[n-2] ^ a[0]):
    pass
else:
    ans = 'No'

print(ans)

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')
elif len(a)==2:
    print('Yes')
else:
    print('No')