Problem:


Score : 300 points

Problem Statement

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N camels standing in a circle.
Snuke will put one of his hats on each of these camels.

If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.

The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.

What is XOR?

The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.

For example, 3 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

If we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.

Sample Input 2

4
1 2 4 8

Sample Output 2

No

There is no such way to distribute the hats; the answer is No.



Sample input:
3
1 2 3


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

dic = defaultdict(int)


# 3の倍数個
if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
    
    # 整数の種類数で分岐
    if n_kind == 3:
        # 3つの整数で xorの関係を作れるか判定
        is_xor = False
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] == values[k] or values[k] ^ values[i] == values[j] or values[j] ^ values[k] == values[i]:
                        is_xor = True

        
        # 3つの整数がそれぞれ N/3個であるか判定
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        # 2つの整数がそれぞれ 2N/3個であり、0がN/3子であるか判定
        is_in_zero = True
        if 0 in values:
            is_in_zero = False

        is_n_valid = True
        if is_in_zero:
            for k, v in dic.items():
                if k == 0:
                    if v != N/3:
                        is_n_valid = False
                else:
                    if v != N * (2/3):
                        is_n_valid = False

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


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

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


else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

dic = defaultdict(int)


# 3の倍数個
if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
    
    # 整数の種類数で分岐
    if n_kind == 3:
        # 3つの整数で xorの関係を作れるか判定
        is_xor = False
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] == values[k]:
                        is_xor = True

        
        # 3つの整数がそれぞれ N/3個であるか判定
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        # 2つの整数がそれぞれ 2N/3個であり、0がN/3子であるか判定
        is_in_zero = True
        if 0 in values:
            is_in_zero = False

        is_n_valid = True
        if is_in_zero:
            for k, v in dic.items():
                if k == 0:
                    if dic[k] != N/3:
                        is_n_valid = False
                else:
                    if dic[k] != N * (2/3):
                        is_n_valid = False

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


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

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


else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

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

Submission status: Wrong Answer

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

if N%3!=0:
  if max(a)==0:
    print("Yes")
  else:
    print("No")
else:
  f=True
  M = N//3
  while a[-1]!=0 and f:
    f = np.count_nonzero(a % 2) in [2*M,N]
    a //= 2
  if f:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

if N%3!=0:
  if max(a)==0:
    print("Yes")
  else:
    print("No")
else:
  f=True
  M = N//3
  while a[-1]!=0 and f:
    f = np.count_nonzero(a % 2) == 2*M
    a //= 2
  if f:
    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))
k=len(b)
cnt=0
if not all(a):
    print('Yes')
    exit()
flag=False

if a.count(0)==n/3:
    flag=True

for x in range(k-2):
    if flag:
        if a.count(b[x])==2*n/3:
            print('Yes')
            exit()
    for y in range(x+1,k-1):
        for z in range(y+1,k):
            if b[x]^b[y]^b[z]==0:
                if a.count(b[x])==a.count(b[y])==a.count(b[z])==n/3:
                    print('Yes')
                    exit()

print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
if not all(a):
    print('Yes')
    exit()
if a.count(a[-1])==2*n/3 and a.count(0)==n/3:
    print('Yes')
    exit()
b=list(set(a))
k=len(b)
cnt=0
for x in range(k-2):
    for y in range(x+1,k-1):
        for z in range(y+1,k):
            if b[x]^b[y]^b[z]==0:
                if a.count(b[x])==a.count(b[y])==a.count(b[z])==n/3:
                    print('Yes')
                    exit()

print('No')

Submission status: Wrong Answer

Solution code:
# coding: Shift-Jis
 

N = int(input())
a =[]
if N < 3:
	print("No")
	exit()

for i in input().split():
	a.append(int(i))

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

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



print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: Shift-Jis
 

N = int(input())
a =[]
if N < 3:
	print("No")
	exit()

for i in input().split():
	a.append(int(i))

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

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

print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: Shift-Jis
 

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

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

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

print("Yes")

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    _ = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]
    z = 0

    for a in a_lists:
        z ^= a

    if z == 0:
        print("yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
l=len(dic)
if n%3!=0:
  print('No')
else:
  if l==1:
    if 0 in dic:
      print('Yes')
    else:
      print('No')
  elif l==2:
    if 0 in dic:
      if dic[0]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  elif l==3:
    arr2=list(dic.keys())
    arr3=list(dic.values())
    if (arr2[0]^arr2[1]^arr2[2])==0:
      if dic[arr2[0]]==n//3 and dic[arr2[1]]==n//3 and dic[arr2[2]]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
l=len(dic)
if n%3!=0:
  print('No')
else:
  if l==1:
    if 0 in dic:
      print('Yes')
    else:
      print('No')
  elif l==2:
    if 0 in dic:
      if dic[0]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  elif l==3:
    arr2=list(dic.keys())
    arr3=list(dic.values())
    if (arr2[0]^arr2[1]^arr2[2])==0:
      if arr3[0]==n//3 and arr3[1]==n//3 and arr3[2]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
l=len(dic)
if n%3!=0:
  print('No')
else:
  if l==1:
    arr2=list(dic.keys())
    if arr2[0]==0:
      print('Yes')
    else:
      print('No')
  elif l==2:
    arr2=list(dic.values())
    if (arr2[0]==(2*n)//3 and arr2[1]==n//3) or (arr2[0]==n//3 and arr2[1]==(2*n)//3):
      print('Yes')
    else:
      print('No')
  elif l==3:
    arr2=list(dic.keys())
    arr3=list(dic.values())
    if (arr2[0]^arr2[1]^arr2[2])==0:
      if arr3[0]==n//3 and arr3[1]==n//3 and arr3[2]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
l=len(dic)
if n%3!=0:
  print('No')
else:
  if l==1:
    arr2=list(dic.keys())
    if arr2[0]==0:
      print('Yes')
    else:
      print('No')
  elif l==2:
    arr2=list(dic.values())
    if (arr2[0]==(2*n)//3 and arr2[1]==n//3) or (arr2[0]==n//3 and arr2[1]==(2*n)//3):
      print('Yes')
    else:
      print('No')
  elif l==3:
    arr2=list(dic.keys())
    if (arr2[0]^arr2[1]^arr2[2])==0:
      print('Yes')
    else:
      print('No')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"
elif (len(b) == 1):
    if list(b.keys())[0] == 0:
        ans = "Yes"
    else:
        ans = "No"
elif (len(b) == 2):
    if n % 3 == 0:
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[1])):
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"
else:
    ans = "No"
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

def solve():

    if N % 3 != 0:
        return all(a == 0 for a in A)



    counts, vals = zip(*sorted((c,v) for v,c in Counter(A).items()))

    if len(counts) == 1:
        return vals[0] == 0
    elif len(counts) == 2:
        return counts[0] == counts[1]*2 and vals[1] == 0
    elif len(counts) == 3:
        return counts[0] == counts[2] and (vals[0]^vals[1]^vals[2])==0
    else:
        return False

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

def solve():
    counts = sorted(Counter(A).values())
    if N % 3 == 0:
        if len(counts) == 1:
            return True
        elif len(counts) == 2:
            return counts[0] == counts[1]*2
        elif len(counts) == 3:
            return counts[0] == counts[2]
        else:
            return False
    else:
        return len(counts) == 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a_set = set(a)
if len(a_set) == 1:
    if a_set == {0}:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    a_set = list(a_set)
    c = a_set[0] ^ a_set[1]
    if N % 3 == 0 and a.count(a_set[0]) == a.count(a_set[1]) and (c == a_set[0] or c == a_set[1]):
        print('Yes')
    else:
        print('No')
elif len(a_set) == 3:
    a_set = list(a_set)
    flag = 0
    if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
        flag = 1
    if N % 3 == 0 and flag == 1 and a_set[0] ^ a_set[1] == a_set[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

for i in a:
    if (x^i) > x:
      c+=1

if c>n:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

flag=True

for i in a:
    if (x^i) > x:
        flag = False
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = max(a)
y = min(a)

flag=True

for i in a:
    if (x^i) > x:
        flag = False

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-2):
    if a[i]^a[i+1]!=a[i+2]:
        c=1
        break
if a[n-2]^a[n-1]!=a[0] or a[n-1]^a[0]!=a[1]:
    c=1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = inl()
h = {} # defaultdict(int)
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
x = a[0] if a[0]!=0 else a[1] if a[1]!=0 else a[2]
if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]] and (a[0]^a[1])==a[2]:
    print('Yes')
elif len(h.keys()) == 2 and (a[0]==0 or a[1]==0 or a[2]==0) and h[0]*2 == h[x]:
    print('Yes')
elif len(h.keys()) == 1 and a[0]==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = inl()
h = {} # defaultdict(int)
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
x = a[0] if a[0]!=0 else a[1] if a[1]!=0 else a[2]
if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]] and a[0]^a[1]==a[2]:
    print('Yes')
elif len(h.keys()) == 2 and (a[0]==0 or a[1]==0 or a[2]==0) and h[0]*2 == h[x]:
    print('Yes')
elif len(h.keys()) == 1 and a[0]==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = inl()
h = {} # defaultdict(int)
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
x = a[0] if a[0]!=0 else a[1] if a[1]!=0 else a[2]
if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]]:
    print('Yes')
elif len(h.keys()) == 2 and (a[0]==0 or a[1]==0 or a[2]==0) and h[0]*2 == h[x]:
    print('Yes')
elif len(h.keys()) == 1 and a[0]==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int, input().split()))
a = num[0]
for i in range(1, len(num)):
    a = a ^ num[i]

if a == 0:
    print("Yes")
else:
    print("Np")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = inl()
h = {} # defaultdict(int)
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]]:
    print('Yes')
elif len(h.keys()) == 2 and (a[0]==0 or a[1]==0) and h[a[0]]*(1 if a[0]!=0 else 2) == h[a[1]]*(1 if a[1]!=0 else 2):
    print('Yes')
elif len(h.keys()) == 1 and a[0]==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = inl()
h = {} # defaultdict(int)
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = inl()
h = {} # defaultdict(int)
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

from collections import Counter

def solve(N, A):
    cs = Counter(A)
    k = list(cs.keys())
    if len(k) == 1 and A[0] == 0:
        return True
    if len(k) != 3:
        return False
    v = list(cs.values())
    # print(k, v)
    if k[0] ^ k[1] ^ k[2] == 0 and v[0] == v[1] == v[2]:
        return True
    return False

if solve(N, A):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = "Yes"
for i in range(n):
    if i < n-2:
        if a[i+2] == a[i+1] ^ a[i]:
            continue
        else:
            ans = "No"
            break
    elif i == n-2:
        if a[0] == a[i+1] ^ a[i]:
            continue
        else:
            ans = "No"
            break
    elif i == n-1:
        if a[1] == a[i] ^ a[0]:
            continue
        else:
            ans = "No"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=list(map(int,input().split()))
ia=a=aa.pop()
ib=b=aa.pop()
while aa:
    c = a^b
    if c in aa:
        aa.remove(a^b)
        a = b
        b = c
    else:
        print('No')
        sys.exit()
if a^b == ia and b^ia == ib:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=list(map(int,input().split()))
a=aa.pop()
b=aa.pop()
while aa:
    c = a^b
    if c in aa:
        aa.remove(a^b)
        a = b
        b = c
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:

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

a.sort()
import collections

count = collections.Counter(a)
modulo = (N%3)

L = len(count)

if modulo == 0:
    if L < 4:
        tmp = 0
        for i in count:
            tmp = tmp^i
        if tmp == 0:
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
else :
    if L < 2:
        tmp = 0
        for i in count:
            tmp = tmp^i
        if tmp == 0:
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
    
print(ans)

Submission status: Wrong Answer

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

a.sort()
import collections

count = collections.Counter(a)
modulo = (N%3)

L = len(count)

if modulo == 0:
    if L < 4:
        ans = 'Yes'
    else:
        ans = 'No'
else :
    if L < 2:
        ans = 'Yes'
    else:
        ans = 'No'
    
print(ans)

Submission status: Wrong Answer

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

tmp = 0
for data in a:
    tmp = tmp ^ data

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

Submission status: Wrong Answer

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

result=True
for i in range(N):
	l=i-1
	r=i+1
	if l<0:
		l=N-1
	if r==N:
		r=0
	
	x=a[r]^a[l]
	if a[i]!=x:
            result=False
            break
if result:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

flagF = 0
flagL = 0
flagT = 0

for i in range(n):
    if(i==0):
        if((a[i+1]^a[n-1])==a[i]):
            flagF = 1
        else:
            break
    elif(i==(n-1)):
        if((a[0]^a[i-1])==a[i]):
            flagL = 1
        else:
            break
    elif(0<i<n-1):
        if((a[i-1]^a[i+1])==a[i]):
            flagT = 1
        else:
            flagT = 0
            break
flag = (flagF+flagL+flagT)
if(flag==3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

flagF = 0
flagL = 0
flagT = 0

for i in range(n):
    if(i==0):
        if((a[i+1]^a[n-1])==a[i]):
            flagF = 1
        else:
            break
    elif(i==(n-1)):
        if((a[0]^a[i-1])==a[i]):
            flagL = 1
        else:
            break
    elif(0<i<n-1):
        if((a[i-1]^a[i+1])==a[i]):
            flagT = 1
        elif(a[i-1]^a[i+1]!=a[i]):
            flagT = 0
            break
if(flagF==1 and flagL==1 and flagT==1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def Xor (x,y):
    return ((x and y) or (not x and not y))

def xor (x,y):
    n=len(x)
    ans=[Xor(x[i],y[i]) for i in range(n)]
    return ans

def bina (x):
    da=[True for i in range(32)]
    for i in da:
        i=bool(x%2)
        i/=2
    return da

def check(x,y,z):
    return xor(bina(x),bina(y))==bina(z)


n=int(input())
da=list(map(int,input().split()))
co=set(da)
m=len(co)
ju=False
if m==1:
    if da[0]==0:
        ju=True
elif m==2:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0]
        for (i,j) in zip(range(3),gg.values()):
            hoge[i]=j
        if hoge[1]==hoge[0]*2:
            ju=check(hoge[1],hoge[1],hoge[0])
        elif hoge[0]==hoge[1]*2:
            ju=check(hoge[0],hoge[0],hoge[1])
elif m==3:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0,0]
        for (i,j) in zip(range(3),gg.values()):
            hoge[i]=j
        if hoge[0]==n/3 and hoge[1]==n/3 and hoge[2]==n/3:
            ju=check(da[0],da[1],da[2])
if ju:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

flagF = 0
flagL = 0
flagT = 0
for i in range(n):
    if(i==0):
        if(a[i+1]^a[n-1]==a[i]):
            flagF += 1
    elif(i==(n-1)):
        if(a[0]^a[i-1]==a[i]):
            flagL += 1
    else:
        if(a[i-1]^a[i+1]==a[i]):
            flagT = 1
        elif(a[i-1]^a[i+1]!=a[i]):
            flagT = 0
            break
if(flagF==1 and flagL==1 and flagT==1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def Xor (x,y):
    return ((x and y) or (not x and not y))

def xor (x,y):
    n=len(x)
    ans=[Xor(x[i],y[i]) for i in range(n)]
    return ans

def bina (x):
    da=[True for i in range(32)]
    for i in da:
        i=bool(x%2)
        i/=2
    return da

def check(x,y,z):
    return xor(bina(x),bina(y))==bina(z)


n=int(input())
da=list(map(int,input().split()))
co=set(da)
m=len(co)
ju=False
if m==1:
    if da[0]==0:
        ju=True
elif m==2:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0]
        for (i,j) in zip(hoge,gg.values()):
            i=j
        if da[1]==da[0]*2:
            ju=check(da[1],da[1],da[0])
        elif da[0]==da[1]*2:
            ju=check(da[0],da[0],da[1])
elif m==3:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0,0]
        for (i,j) in zip(range(3),gg.values()):
            hoge[i]=j
        if hoge[0]==n/3 and hoge[1]==n/3 and hoge[2]==n/3:
            ju=check(da[0],da[1],da[2])
if ju:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def Xor (x,y):
    return ((x and y) or (not x and not y))

def xor (x,y):
    n=len(x)
    ans=[Xor(x[i],y[i]) for i in range(n)]
    return ans

def bina (x):
    da=[True for i in range(32)]
    for i in da:
        i=bool(x%2)
        i/=2
    return da

def check(x,y,z):
    return xor(bina(x),bina(y))==bina(z)


n=int(input())
da=list(map(int,input().split()))
co=set(da)
m=len(co)
ju=False
if m==1:
    if da[0]==0:
        ju=True
elif m==2:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0]
        for (i,j) in zip(hoge,gg.values()):
            i=j
        if da[0]==da[1]*2:
            ju=check(da[1],da[1],da[0])
        elif da[1]==da[0]*2:
            ju=check(da[0],da[0],da[1])
elif m==3:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0,0]
        for (i,j) in zip(range(3),gg.values()):
            hoge[i]=j
        if hoge[0]==n/3 and hoge[1]==n/3 and hoge[2]==n/3:
            ju=check(da[0],da[1],da[2])
if ju:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def Xor (x,y):
    return ((x and y) or (not x and not y))

def xor (x,y):
    n=len(x)
    ans=[Xor(x[i],y[i]) for i in range(n)]
    return ans

def bina (x):
    da=[True for i in range(32)]
    for i in da:
        i=bool(x%2)
        i/=2
    return da

def check(x,y,z):
    return xor(bina(x),bina(y))==bina(z)


n=int(input())
da=list(map(int,input().split()))
co=set(da)
m=len(co)
ju=False
if m==1:
    if da[0]==0:
        ju=True
elif m==2:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0]
        for (i,j) in zip(hoge,gg):
            i=j
        if da[0]==da[1]*2:
            ju=check(da[1],da[1],da[0])
        elif da[1]==da[0]*2:
            ju=check(da[0],da[0],da[1])
elif m==3:
    gg={}
    if n%3==0:
        for i in co:
            gg[i]=0
        for i in da:
            gg[i]+=1
        hoge=[0,0,0]
        for (i,j) in zip(range(3),gg.values()):
            hoge[i]=j
        if hoge[0]==n/3 and hoge[1]==n/3 and hoge[2]==n/3:
            ju=check(da[0],da[1],da[2])
if ju:
    print('Yes')
else:
    print('No')