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:
import math

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

if len(unique_a) == 1 :
    print("Yes")
elif len(unique_a) == 3 :
    if a.count(unique_a[0]) == a.count(unique_a[1]) and  a.count(unique_a[0]) == a.count(unique_a[2]):
        if unique_a[0] == unique_a[1] ^ unique_a[2] or unique_a[1] == unique_a[0] ^ unique_a[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
a_list = [int(elem) for elem in fin().split()]

a_set = set(a_list)

all_xor = 0
for each_a in a_list:
    all_xor = all_xor ^ each_a

if len(a_list) % 3 == 0:
    if all_xor == 0:
        print('Yes')
    else:
        print('No')
else:
    if all_xor in a_set:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a_list = list(map(int, input().split()))
ans = "No"
a_list.sort()
a_list.insert(0, a_list[-1])
a_list.append(a_list[1])
for i in range(1, N + 1):
    if a_list[i-1] ^ a_list[i+1] != a_list[i]:
        break
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

k = {}
for i in range(N):
    if not A[i] in k:
        k[A[i]] = 1
    else:
        k[A[i]] += 1
B = 0
a = 0
print(k)
if len(k.keys()) == 3:
    B = 0
    for key, val in k.items():
        if val == N // 3:
            a += 1
        B = B ^ key
elif len(k.keys()) == 2:
    for key, val in k.items():
        if val == N // 3 and key == 0:
            a += 1
        elif val == N // 3 * 2:
            a += 2
    B = 0

if N % 3 == 0 and B == 0 and a == 3:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
a=[]
a1=0
a2=0
a3=0
xor = "true"
if int(input())%3!=0:
  print("No")
else:
  a = list(map(int,input().split()))
  for i in range(len(a)):
    if xor == "true":
      if a[i] == 1:
        a1 = a1+1
      if a[i] == 2:
        a2=a2+1
      if a[i] == 3:
        a3=a3+1
      if a[i]>3:
        xor="false"
  if a1 == a2 == a3:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    an = list(map(int, input().split()))
    an.sort()

    ans = True

    for i, a in enumerate(an):
        if a != an[i - 1] ^ an[(i + 1) % N]:
            ans = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(A)
K = c.keys()

ans = "No"
if len(K)==3:
    B = []
    for k in K:
        B.append(k)
    if c[B[0]]==c[B[1]] and c[B[1]]==c[B[2]] and int(B[0])^int(B[1])==int(B[2]):
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
shurui={}
a=list(map(int,input().split()))
if N%3==0:
  for i in range(N):
    if a[i] in shurui:
      shurui[a[i]]+=1
    else:
      shurui[a[i]]=1
  kagi=list(shurui.keys())
  atai=list(shurui.values())
  if len(shurui)==1:
    if kagi[0]^kagi[0]==kagi[0]:
      print('Yes')
    else:
      print('No')
  elif len(shurui)==2:
    if atai[0]*2==atai[1]:
      if kagi[0]^kagi[0]==kagi[1]:
        print('Yes')
      else:
        print('No')
    elif atai[1]*2==atai[0]:
      if kagi[1]^kagi[1]==kagi[0]:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  elif len(shurui)==3:
    if atai[0]==atai[1]==atai[2]:
      if kagi[0]^kagi[1]==kagi[2]:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

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

import collections
c = collections.Counter(a)
unique = list(set(a))

from operator import xor
v = []
for k in c.keys():
    v.append(c[k])
v.sort()

flag = False
if n % 3 == 0:
    if v == [n] and unique[0] == 0:
        flag = True
    if v == [n // 3, n // 3 * 2]:
        if c[unique[0]] == n // 3 and c[unique[0]] == 0:
                flag = True
        elif c[unique[0]] == n // 3 * 2 and c[unique[1]] == 0:
                flag = True
    if v == [n // 3, n // 3, n // 3]:
        if xor(unique[0], unique[1]) == unique[2] and xor(unique[1], unique[2]) == unique[0] and xor(unique[2], unique[0]) == unique[1]:
            flag = True
else:
    if v == [n]:
        flag = True

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

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
a = [int(x) for x in input().split()]
removelist = [0]*N
for i in range(N):
    for k in range(i):
        A = copy.deepcopy(a)
        first = A.pop(i)
        f = 0
        f += first
        second = A.pop(k)
        s = 0
        s += second
        for j in range(2, N):
            if (f ^ s) in A:
                A.remove(f ^ s)
                f, s = s, f ^ s
            else:
                print("No")
                exit()
if s ^ second != first:
    print("No")
    exit()
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import collections
n=input()
a=list(map(int,input().split()))
b=set(a)
c=list(b)
c.sort()
cnt=collections.Counter(a)
if len(b)==1:
  if c[0]==0:
    print('Yes')
if len(b)==2:
  if c[0]==0 and cnt[1]%2==0:
    print('Yes')
if len(b)==3:
  if cnt[c[0]]==cnt[c[1]]==cnt[c[2]]:
    if c[0]^c[1]==c[2]:
      print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import collections

N = input()
N = int(N)
a = [ int(i) for i in input().split()]
c = collections.Counter(a)
hoge = False

def check(i,j):
    for k in range(len(a)-2):
        if c[i^j] == 0:
            return False
        i = j
        j = i^j
    return True

for  i in range(len(a)-1):
    for j in range(i+1,len(a)):
        if check(a[i],a[j]):
            hoge = True
            break
        else:
            break
    else:
        continue
    break

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

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        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('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
first = 0
last = 1
pattern = True
UsedCap = []
for i in range(1,len(A)):
    # last = i
    # lastnum = A[last]
    next = A[first] ^ A[last]
    # print(next,A)
    if next in A and not next in UsedCap:
        # A.pop(first)
        first = last
        UsedCap.append(A[last])
        last = A.index(next)

    else:
        pattern = False
        break

# print(UsedCap)
if pattern == False:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
import cmath
N = input()
N = int(N)
#nums = []
nu = input().split()
nui = [int(s) for s in nu]
nus = set(nui)
nul = list(nus)

if(len(nul)==3):
    a = nul[0]
    b = nul[1]
    c = nul[2]
    a_s = list(format(a,"034b"))
    b_s = list(format(b,"034b"))
    c_s = list(format(c,"034b"))
    
    a_si = [int(s) for s in a_s]
    b_si = [int(s) for s in b_s]
    c_si = [int(s) for s in c_s]
    
    a_np = np.array(a_si)
    b_np = np.array(b_si)
    c_np = np.array(c_si)
    
    sum = a_np + b_np + c_np
    
    amari = sum%2
    
    ind = np.where(amari==1)
    
    if(len(ind[0])==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

print('No')

Submission status: Wrong Answer

Solution code:
def check(b, l):
    for i in l:
        if b == i:
            continue
        #print(b ^ i)
        if not((b ^ i) in l):
            print("No")
            exit()
    
    print("Yes")
    exit()

n = int(input())
lst = list(map(int, input().split()))
x = lst

base = x[0]
check(base, x)

Submission status: Wrong Answer

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

xorNeighbor = 0
xorNeighborS = 0
nonZero = []

for i in range(1, len(a)-1):
    xorNeighbor = a[i-1] ^ a[i] ^ a[i+1]
    xorNeighborS ^= xorNeighbor
    if xorNeighbor:
        nonZero.append(xorNeighbor)

if xorNeighborS:
    nonZero.append(xorNeighborS)

if len(nonZero) == 0:
    print("Yes")
else:
    #print(nonZero)
    try:
        while len(nonZero):
            removeVal = nonZero[0]
            nonZero.remove(removeVal)
            nonZero.remove(removeVal)
        print("Yes")
    except:
        print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

s = input().split()
N=int(s[0])
s = input().split()
a=[]
a=copy.copy(s)
count=0
for k in range(1,N):
    s=copy.copy(a)
    for j in range(1,N):
        t=s[j]
        s[j]=s[k]
        s[k]=s[j]
        for i in range(N):
            if i==0 :
                if int(s[i])==int(s[N-1])^int(s[i+1]):
                    count+=1
            elif i==N-1:
                if int(s[i])==int(s[i-1])^int(s[0]):
                    count += 1
            else:
                if int(s[i])==int(s[i-1])^int(s[i+1]):
                    count += 1
    if count==N:
        print('True')
        break

if count != N:
    print('False')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
candidates = list(set(As))

if len(candidates) == 1:
    if 0 in candidates:
        print('Yes')
    else:
        print('No')
elif len(candidates) == 2:
    a, z = candidates
    if a < z:
        a, z = z, a

    bits = format(z, 'b')
    if a == 0 and bits.find('0') == -1:
        count_a = 0
        count_z = 0
        for element in As:
            if element == 0:
                count_z += 1
            else:
                count_a += 1
        else:
            if count_a == count_z:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
elif len(candidates) > 3:
    print('No')
else:
    a, b, c = candidates[0], candidates[1], candidates[2]
    if a ^ b != c:
        print('No')
    else:
        count_a = 0
        count_b = 0
        count_c = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == b:
                count_b += 1
            elif element == c:
                count_c += 1
        else:
            if count_a == count_b == count_c:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        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:
N = int(input())
ai = [int(x) for x in input().split()]
if N > 3:
  print("No")
  exit()
bi = sum([int(bin(x)[2:]) for x in ai])
if list(set(str(bi)))[0] == "2":
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=[int(_) for _ in input().split()]
c=collections.Counter(a)
l=len(c.keys())
k=list(c.keys())
v=list(c.values())
if l > 3:
    print("No")
elif l == 3:
    if k[0]^k[1]^k[2] == 0 and v[0]==v[1]==v[2] and n%3==0:
        print("Yes")
    else:
        print("No")
elif l == 2:
    if k[0] == 0:
        if v[0] == v[1]*2 and n%3==0:
            print("Yes")
        else:
            print("No")
    elif k[1] == 0:
        if v[1] == v[0]*2 and n%3==0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif l == 1:
    if k[0] == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    an = list(map(int, input().split()))

    ans = True

    for i, a in enumerate(an):
        if a != an[i - 1] ^ an[(i + 1) % N]:
            ans = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
for i in c.values():
    b.append(i)
for i in range(len(b)):
    if len(b)%3!=0:
        print('No')
        break
    elif b[i]!=b[i+1] and i!=len(b)-2:
        print('No')
        break
    elif i==len(b)-2:
        print('Yes')
        break
    else:
        pass

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
first = 0
last = 1
pattern = True
UsedCap = []
for i in range(1,len(A)):
    # last = i
    # lastnum = A[last]
    next = A[first] ^ A[last]
    print(next,A)
    if next in A and not next in UsedCap:
        # A.pop(first)
        first = last
        UsedCap.append(A[last])
        last = A.index(next)

    else:
        pattern = False
        break

print(UsedCap)
if pattern == False:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

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

a = sorted(a)
flag = True
first = a.pop(0)
pp = first
p = a.pop(0)
for x in a:
    if x ^ pp != p:
        flag = False
        break
    pp = p
    p = x
if first ^ pp != p:
    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))
if n%3!=0:
    print('No')
else:
    if len(b)!=3:
        print('No')
    elif b[0]^b[1]==b[2]:
        if a.count(b[0])==a.count(b[1])==a.count(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()))
#n = 9
#a = [1,2,3,1,2,3,1,2,3]
if n >=4:
  if n % 3 != 0:
    if a.count(0) == n:
      print("Yes")
    else :
      print("No")
  else:
    s = set(a)
    if len(s)!=3:
      print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3 and a.count(l[2])==n/3):
        print("Yes")
      else:
        print("No")
else:
  if a[0]^a[1] == a[2] and a[1]^a[2] == a[0] and a[2]^a[0] == a[1]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    a = [int(i) for i in input().split()]
    count = 0
    if (a[0] != a[N - 1] ^ a[1]):
        count += 1
    if (a[N - 1] != a[N - 2] ^ a[0]):
        count += 1
    for i in range(1, N - 1):
        if (a[i] != a[i - 1] ^ a[i + 1]):
            count += 1
    if (count == 0):
        print("Yes")
    else:
        print("No")
resolve()

Submission status: Wrong Answer

Solution code:

a = int(input())
x = list(map(int,input().split()))
ax = list(set(x))
x.sort()
ax = list(set(x))
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
if len(ax) < 3:
    if (sum(x) == 0) :
        print("Yes")
        exit()
    if (len(ax)) <2:
        print("No")
        exit()
    if x.count(0)*2 == x.count(ax[1]) and len(x) == x.count(0) + x.count(ax[1]):
        print("Yes")
        exit()
        
    print("No")
    exit()
t = (len(x) == x.count(ax[0]) + x.count(ax[1]) + x.count(ax[2])) * (x.count(ax[1]) == x.count(ax[0]) and x.count(ax[0]) == x.count(ax[2]))

y(1,t)

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]

input_size = len(input_num)-1
for i in range(len(input_num)):
    left = i-1
    right = i+1
    if left < 0:
        left = input_size
    if right > input_size:
      right = 0
#     print(input_num[left])
#     print(input_num[right])
    if input_num[left]^input_num[right] == input_num[i]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:

import math

N = int(input())

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

def xor(x1,x2):
    xdigit = math.ceil(math.log2(max(x1+1, x2+1)))
    num = 0
    
    #print(x1, x2)
    
    for i in range(xdigit):
        dig_x1 = x1 // (2**(xdigit-i-1))
        dig_x2 = x2 // (2**(xdigit-i-1))
        
        #print("x", dig_x1, dig_x2)
        
        if dig_x1 != dig_x2:
            num += 2**(xdigit-i-1)
            
        if dig_x1 == 1:
            x1 -= 2**(xdigit-i-1)
            
        if dig_x2 == 1:
            x2 -= 2**(xdigit-i-1)
    return num

is_exist = True

for camel in range(N):
    if camel == N-1:
        furt = 0
    else:
        furt = camel + 1
        
    if camel == 0:
        prev = N-1
    else:
        prev = camel -1
         
    num_xor = xor(nums[prev], nums[furt])
    
    #print(num_xor)
    
    #print(camel, num_xor, nums[camel])
    
    if num_xor != nums[camel]:
        is_exist = False
        break


if is_exist == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

D = {}

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

if len(D) == 1 :
    if D.get(0,0) == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 2 :
    if D.get(0,0)*3 == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 3 :
    if len(A) % 3 != 0 :
        ans = "No"
    else :
        for k in D :
            if D[k]*3 != N :
                ans = "No"
        else :
            ans = "Yes"
else :
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
a = list(map(int, input().split()))
first = a.pop(0)
aa = list(itertools.permutations(a))

answer = "No"
for i in range(len(aa)):
  alist = list(aa[i])
  alist.insert(0, first)
  for j in range(len(alist) - 1):
    if alist[j] != (alist[j - 1] ^ alist[j + 1]):
      answer = "Yes"
      break
  if answer == "Yes":
    break
    
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
als = list(map(int,input().split()))
ans = 'No'
sett = n//3
als.sort()
if als[0] == als[n-1]:
    ans = 'Yes'
if n%3 == 0:
    co = [als[0]]*sett + [(als[0]^als[n-1])]*sett + [als[n-1]]*sett
    if co == als:
        ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
from random import shuffle
n = int(input())
lst = list(map(int,input().split()))
flg = 1
for j in range(1):
  for i in range(len(lst)):
    if i+1 == len(lst):
      if bin(lst[i]) != bin(lst[i-1] ^ lst[0]):
        flg = 0
        break
    elif bin(lst[i]) != bin(lst[i-1] ^ lst[i+1]):
      flg = 0
      break
    shuffle(lst)
  if flg == 0:
    break
if n >= 1000:
  print("Yes")
elif flg == 1:
  print("Yes")
elif flg == 0:
  print("No")

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]

input_size = len(input_num)-1
for i in range(len(input_num)):
    left = i-1
    right = i+1
    if left < 0:
        left = input_size
    if right >= input_size:
      right = 0
#     print(input_num[left])
#     print(input_num[right])
    if input_num[left]^input_num[right] == input_num[i]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
W = list(map(int, input().split()))
c = collections.Counter(W)
if len(c.keys()) >= 4:
  print('No')
if len(c.keys()) == 1:
  if c.get(0, False) == False:
    print('No')
  else:
    print('Yes')
if len(c.keys()) == 2:
  num = list(c.values())
  num = sorted(num)
  if num[0]*2 == num[1]:
    print("Yes")
  else:
    print("No")
if len(c.keys()) == 3:
  num = list(c.values())
  if num[0] == num[1]:
    if num[0] == num[2]:
      print("Yes")
  else:
    print("No")

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 i == (N-1):
        b = a[i-1] ^ a[0]
    elif a[i] != b:
        count += 1
if count == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
inp = input()
n = int(inp)
inp = input()
split_inp = inp.split()
if n % 3 != 0:
    print("No")
    exit()
# 数字を3つのグループに分けていく．
# 3種類以上の数字があればno
numbers = {}
for str_number in split_inp:
    if str_number not in numbers:
        numbers[str_number] = 1
    else:
        numbers[str_number] += 1
    if len(numbers) > 3:
        print("No")
        exit()
if len(numbers) != 3:
    print("No")
    exit()
# 均等に3当分されている
number_list = [i for i in numbers.values()]
if number_list[0] != number_list[1] or number_list[1] != number_list[2]:
    print("No")
    exit()


def number_count(k1, k2, k3, count_n):
    count = 0
    if k1 == count_n:
        count += 1
    if k2 == count_n:
        count += 1
    if k3 == count_n:
        count += 1
    return count


# ビット列に同時に直す.下の桁から見ていき，0,1,1になっていなければno
n_list = [i for i in numbers.keys()]
n1 = int(n_list[0])
n2 = int(n_list[1])
n3 = int(n_list[2])
while n1 != 0 or n2 != 0 or n3 != 0:
    # 一番下の桁を取り出す
    c1 = n1 % 2
    c2 = n2 % 2
    c3 = n3 % 2
    n1 = n1 // 2
    n2 = n2 // 2
    n3 = n3 // 2
    # 1,1,0の組み合わせでなければno
    count1 = number_count(c1, c2, c3, 1)
    count0 = number_count(c1, c2, c3, 0)
    if (count1 != 2 or count0 != 1) and count0 != 3:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
N = int(input())
A = [int(x) for x in input().split()]

cnt = {}

kind = 0
for a in A:
    if not a in cnt:
        kind += 1
        cnt[a] = 0
    if kind > 3:
        break
    cnt[a] += 1

nums = list(cnt.keys())
if kind == 3 and cnt[nums[0]] == cnt[nums[1]] == cnt[nums[2]] and nums[0] ^ nums[1] == nums[2]:
    print("Yes")
elif kind == 1 and nums[0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(1, n):
            b = a[0]^a[i]
            if b in a:
                pass
            else:
                flag = 1
                break

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

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        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:
n = int(input())

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

a = True

for i in range(n):
  if i == 0:
    next_result = cap_list[1] ^ cap_list[n-1]
    if cap_list[0] != next_result:
      a = False
      break
  elif i == n-1:
    next_result = cap_list[n-2] ^ cap_list[0]
    if cap_list[i] != next_result:
      a = False
      break
  else:
    next_result = cap_list[i-1] ^ cap_list[i+1]
    if cap_list[i] != next_result:
      a = False
      break

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

Submission status: Wrong Answer

Solution code:
n = int(input())
hat_list = list(map(int, input().split()))
print(hat_list)
b_list = []
for h in hat_list:
    # print(format(h,'b').zfill(10))
    b_list.append(format(h,'b').zfill(10))
print(b_list)
for n in range(10):
    test_list = []
    for b in b_list:
        test_list.append(b[n])
    if test_list.count('1') == test_list.count('0') * 2:
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
if n % 3:
    ans = 'No'
else:
    a = sorted(map(int, input().split()))
    m = n // 3
    if a[0] ^ a[m] ^ a[2 * m]:
        ans = 'No'
    elif any(x != y for i, (x, y) in enumerate(zip(a, a[1:]), 1) if i % m):
        ans = 'No'
    else:
        ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():

    n = int(input())
    dataset = set(map(int, input().split()))

    if len(dataset) == 1:
        if list(dataset)[0] == 0:
            print('Yes')
            return
        else:
            print('No')
            return

    li_dataset = list(dataset)
    xor = li_dataset[0] ^ li_dataset[1]

    flag = 0
    if xor in dataset:
        flag = 1

    if len(dataset) <= 3 and n % 3 == 0 and flag:
        print('Yes')

    else:
        print('No')
        
resolve()

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        print('Yes')
        exit()
elif len(count) == 2:
    #, 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 sys
N = int(input())
a_lis = [int(_) % 2 for _ in input().split()]

first = [0, 1, 1]
second = [1, 0, 1]
third = [1, 1, 0]

if set(a_lis) == {0}:
    print('Yes')
    sys.exit()
else:
    if len(a_lis) % 3 == 0:
        ans_lis = [0] * (len(a_lis) // 3)
        for i in range(len(ans_lis)):
            if i >= 1:
                if tmp != a_lis[3 * i: 3 * (i + 1)]:
                    print('No')
                    sys.exit()
            else:
                tmp = a_lis[3 * i: 3 * (i + 1)]
        print('Yes')
                
    else:
        print('No')
        sys.exit()

Submission status: Wrong Answer

Solution code:
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    xor_a = 0
    for i in range(N):
        xor_a ^= A[i]
    if N % 3 == 0:
        return 1 if xor_a == 0 else 0
    elif N % 3 == 1:
        for i in range(N):
            if xor_a ^ A[i] == 0:
                return 1
        return 0
    elif N % 3 == 2:
        for i in range(N):
            for j in range(i):
                if xor_a ^ A[i] ^ A[j] == 0:
                    return 1
        return 0
    raise ValueError()


if __name__ == '__main__':
    inputs = read()
    print('Yes' if solve(*inputs) else 'No')

Submission status: Wrong Answer

Solution code:
input()
a=list(map(int,input().split()))
b=list(set(a))
b.sort()
if b[0]!=0:
    if len(a)%3==0:
        if len(b)==3:
            b=[format(i, '032b') for i in b]
            b=[(int(b[0][i])+int(b[1][i]))%2==int(b[2][i]) for i in range(32)]
            if False in b:
                print("No")
            else:
                print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    if len(b)<3:
        if len(a)%(len(b))==0:
            print("Yes")
        else:
            print("No")
    else:print("No")

Submission status: Wrong Answer

Solution code:
import collections

N = input()
N = int(N)
a = [ int(i) for i in input().split()]
c = collections.Counter(a)
hoge = False

def check(i,j):
    for k in range(len(a)-2):
        if c[i^j] == 0:
            return False
        i = j
        j = i^j
    return True

for  i in range(len(a)-1):
    for j in range(i+1,len(a)):
        if check(a[i],a[j]):
            hoge = True
            break
    else:
        continue
    break

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

Submission status: Wrong Answer

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

def all_zero(a):
    for e in a:
        if e != 0:
            return False
    return True

if N != 3:
    if all_zero(a):
        print("Yes")
    else:
        print("No")
else:
    lst = [0,1,2]
    p = itertools.permutations(lst, 3)
    yes = False
    for perm in p:
        permed_a = []
        for ind in perm:
            permed_a.append(a[ind])
            
        good_perm = True
        
        for i in range(3):
            if permed_a[(i + 1) % 3] != (permed_a[i] ^ permed_a[(i + 2) % 3]):
                good_perm = False
                break
        if good_perm:
            yes = True
            break
    if yes:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))
for i in range(1, N-1, 1):
    if not a[i-1] ^ a[i+1] == i:
        print("No")
        exit()

if not a[N-1] ^ a[1] == 1:
    print("No")
    exit()
elif not a[N-2] ^ a[0]  == N:
    print("No")
    exit()
print("Yes")