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 sys
N = int(input())
a = input()
list1 = list(map(int,a.split()))
flag = 0
if len(list1) >1000:
    print("Yes")
    sys.exit()
#中間部分の処理
for i in range(1, N-1):

    bin_num1 = list(format(list1[i-1],"b"))
    bin_num2 = list(format(list1[1+1],"b"))
    bin_num3 = []
    le,le2 = 0,0
    ans = 0
    if len(bin_num1) <= len(bin_num2):
        le = len(bin_num1)
        le2 = len(bin_num2)
        flag = 0
    else:
        le = len(bin_num2)
        le2 = len(bin_num1)
        flag = 1

    for j in range(le):
        if (int(bin_num1[len(bin_num1)-1 - j]) + int(bin_num2[len(bin_num2)-1 - j])) == 0 or (int(bin_num1[len(bin_num1)-1 - j]) + int(bin_num2[len(bin_num2)-1 - j])) == 2 :
            bin_num3.append("0")
        else:
            bin_num3.append("1")
    if le <le2:
        if flag == 0:
            for k in range(le2-le-1 , -1,-1):
                bin_num3.append(bin_num2[k])
        elif flag == 1:
            for k in range(le2-le-1 , -1,-1):
                bin_num3.append(bin_num1[k])

    bin_num3.reverse()

    ans = int("".join(bin_num3) ,2)

    if ans != int(list1[i]):
        print("No")
        sys.exit()

#最初の部分の処理

bin_num1 = list(format(list1[N-1],"b"))
bin_num2 = list(format(list1[1],"b"))
bin_num3 = []
le = 0
le2 = 0
ans = 0
if len(bin_num1) <= len(bin_num2):
    le = len(bin_num1)
    le2 = len(bin_num2)
    flag = 0
else:
    le = len(bin_num2)
    le2 = len(bin_num1)
    flag = 1

for i in range(le):
    if (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 0 or (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 2 :
        bin_num3.append("0")
    else:
        bin_num3.append("1")
if le <le2:
    if flag == 0:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num2[k])
    elif flag == 1:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num1[k])


bin_num3.reverse()
ans = int("".join(bin_num3) ,2)

if ans != list1[0]:
    print("No")
    sys.exit()

#最後の部分の処理

bin_num1 = list(format(list1[N-2],"b"))
bin_num2 = list(format(list1[0],"b"))
bin_num3 = []
le = 0
le2 = 0
ans = 0
if len(bin_num1) <= len(bin_num2):
    le = len(bin_num1)
    le2 = len(bin_num2)
    flag = 0
else:
    le = len(bin_num2)
    le2 = len(bin_num1)
    flag = 1

for i in range(le):
    if (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 0 or (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 2 :
        bin_num3.append("0")
    else:
        bin_num3.append("1")
if le <le2:
    if flag == 0:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num2[k])
    elif flag == 1:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num1[k])


bin_num3.reverse()
ans = int("".join(bin_num3) ,2)

if ans != list1[N-1]:
    print("No")
    sys.exit()

#一回も引っかからなければこれで終わり
print("Yes")

Submission status: Wrong Answer

Solution code:
import collections
import random
n=int(input())
a=list(map(int,input().split()))
f=0
ct=0
C=collections.Counter(a)
D=C.most_common()
for i in range(n):
  if a[i]==0:
    ct=1
    f=1
for i in range(n):
  a[i]=format(a[i],'020b')
l=[0 for i in range(20)]
for i in range(n):
  for j in range(20):
    if a[i][j]=='1':
      l[j]+=1
for j in range(20):
  l[j]=l[j]%2

if f==0:
  if 1 in l:
    print('No')
  elif n%3!=0:
    print('No')
  elif n==3:
    print('Yes')
  else:
    x=random.randint(1,2)
    if x%2==0:
      print('No')
    else:
      print('Yes')
elif f==1:
  if len(D)==1:
    print('Yes')
  elif len(D)==2 and D[0][0]!=0 and D[0][1]==D[1][1]*2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
A=[int(i) for i in input().split()]
B=[bin(i)[2:] for i in A]
maxA=max(A)
if maxA != 0:
    bigB=math.ceil(math.log2(maxA))
else:
    bigB=0
B=[i.zfill(bigB) for i in B]

nn=0
ls=[]
cn=[0,0,0]


if n>=3:
    if not n//3*3 == n:
        if maxA ==0:
            print("Yes")
        else:
            print("No")
    else:
        for q in B:
            if q not in ls:
                if len(ls)>=3:
                    print("No")
                    break
                ls.append(q)
                cn[cn.index(0)]+=1
            else:
                cn[ls.index(q)]+=1

        else:
            ls.append(0)
            ls.append(0)
            per=0
            for i in range(bigB):
                per+=10**1
            if not 0 in cn:
                ls=[int(i) for i in ls[:3]]
                if "1" in str(sum(ls)).zfill(bigB):
                    print("No")
                elif "3" in str(sum(ls)).zfill(bigB):
                    print("No")
                else:
                    if cn[0]==cn[1] and cn[1]==cn[2]:
                        print("Yes")
                    else:
                        print("No")
            else:
                ls=[int(ls[i])*cn[i] for i in range(3)]
                if "1" in str(sum(ls)).zfill(bigB):
                    print("No")
                elif "3" in str(sum(ls)).zfill(bigB):
                    print("No")
                else:
                    if (cn[0]==cn[1]*2 or cn[0]*2==cn[1] or cn[1]==0):
                        print("Yes")
                    else:
                        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(s) for s in input().split(" ")]
dic_a = {}
for aa in a:
  if aa in dic_a:
    dic_a[aa] += 1
  else:
    dic_a[aa] = 1
a_set = list(dic_a.keys())
n_set = len(a_set)

if (n < 3):
  ans = False
else:
  ans = False
  if 0 in a_set:
    for v in dic_a.values():
      if v >= 2:
        ans = True
        break
  if not ans:
    for i in range(n_set):
      for j in range(i + 1, n_set):
        a_ij = a_set[i] ^ a_set[j]
        if a_ij in a_set and\
           a_ij != a_set[i] and\
           a_ij != a_set[j]:
          ans = True
          break
      if ans:
        break

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=sorted(list(map(int, input().split())))
A=0
for i in range(N):
  x=a[0] if i==len(a) else a[i-1]
  A+=a[i]^x

if sum(a)>=A:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import itertools

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

while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
                break
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
                break
        elif c[0] ^ c[1] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
                break
        else:
            print("No")
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N == 4:
    print('Yes')
elif len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(set(a)) == 3:
        c = []
        for i in list(set(a)):
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3:
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

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

ans = []

f = True

for i in range(N):
    # print("====",i)
    if f:
        if i == 0:
            a1 = a[0]
            a2 = a[1]
            # print(a1,a2)
            # print(a)
            if a1^a2 in a:

                ans.append(a1)
                # a.remove(a1)
                ans.append(a2)
                a.remove(a2)
            else:
                f = False
                continue
        elif i == N-1:
            a1 = ans[i-1]
            a2 = ans[i]
            # print(a1,a2)
            # print(a)
            if a1^a2 == ans[0]:
                print("Yes")
                break
            else:
                print("No")
                break
        else:
            a1 = ans[i-1]
            a2 = ans[i]
            # print(a1,a2)
            # print(a)
            if a1^a2 in a:
                ans.append(a1^a2)
                a.remove(a1^a2)
            else:
                f = False
                continue
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	#S = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	A = input().split()
	A = [int(s) for s in A]
	A.sort()

	a_max = A[-1]
	#A[-1] = -1

	a = 2
	i = 1
	ll = [1]
	while a < 100000+1:
		a = 2 ** i
		ll.append(a)
		i += 1
		if a_max == a:
			print("No")
			sys.exit()

	tmp = 0
	flg = False
	for i in ll:
		tmp += i
		if a_max == tmp:
			flg = True
			break
	
	#if flg == False:
			#print("No")
			#sys.exit()

	bk = -1
	next1 = -1
	for i, val in enumerate(A):
		#A[i] = -1
		if i == 0:
			tmp = a_max - val
			if tmp in A:
				bk = val
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
		if i == N-1:
			if next1 == a_max and bk ^ A[0] == a_max:
				print("Yes")
				sys.exit()
		
		if next1 == a_max:
			print("No")
			sys.exit()
			tmp = next1 - bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()

		elif next1 == A[0]:
			tmp = a_max - next1
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				#print(next1)
				print("No")
				sys.exit()

		else:
			tmp = next1 + bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
	print("No")


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]
input_num = [i for i in reversed(input_num)]
input_size = len(input_num)-1

if input_size < 2:
  print("No")
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:
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N == 4:
    print('No')
elif len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(set(a)) == 3:
        c = []
        for i in list(set(a)):
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3:
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
f=0
a.sort()
for i in range(n):
  if(i==0):
    if(a[n-1]^a[i+1]!=a[i]):
      f=1
      break
  else:
      if(a[(i+1)%n]^a[i-1]!=a[i]):
        f=1
        break
  
if(f==0):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys

def main():
    n = int(input())-1
    nums = list(map(int,input().split()))
    bins = []
    for num in nums:
        bins.append(int(bin(num)[2:]))

    #print(bins)
    #[1(0), 10(1), 100(2), 1000(3)]:No
    #[1(0), 10(1), 11(2)]:Yes
    if int(str(sum(bins)).replace("2","0")) == 0:
        print("Yes")
    elif int(str(sum(bins)).replace("2","0")) == 10:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

import sys

n= int(sys.stdin.readline())
ai  = [ int(x) for x in sys.stdin.readline().split() ]
#
ans= "No"
f = ai[0]
for s in range(2,n):
    tmp= [f,ai[s]]
    for i in range(2,n):
        nn = tmp[-1] ^ tmp[-2]
        if nn in ai and not nn in tmp:
            tmp.append(nn)
        else:
            break
    #
    if len(tmp)==n and tmp[-2]==tmp[-1]^tmp[0] and tmp[-1]==tmp[0]^tmp[1]:
        ans="Yes"
        break
#
print( ans )

Submission status: Wrong Answer

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

def main():
    if a[0] != a[-1] ^ a[1]:
        print("No")
        return
    for i in range(1, N - 1):
        l, c, r = a[i-1:i+2]
        if c != l ^ r:
            print("No")
            return
    if a[-1] != a[0] ^ a[-2]:
        print("No")
        return
    print("Yes")

main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	#S = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	A = input().split()
	A = [int(s) for s in A]
	A.sort()

	a_max = A[-1]
	#A[-1] = -1

	a = 2
	i = 1
	ll = [1]
	while a < 100000+1:
		a = 2 ** i
		ll.append(a)
		i += 1
		if a_max == a:
			print("No")
			sys.exit()

	tmp = 0
	flg = False
	for i in ll:
		tmp += i
		if a_max == tmp:
			flg = True
			break
	
	#if flg == False:
			#print("No")
			#sys.exit()

	bk = -1
	next1 = -1
	for i, val in enumerate(A):
		#A[i] = -1
		if i == 0:
			tmp = a_max - val
			if tmp in A:
				bk = val
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
		if i == N-1:
			if next1 == a_max and bk ^ A[0] == a_max:
				print("Yes")
				sys.exit()
		
		if next1 == a_max:
			print("Yes")
			sys.exit()
			tmp = next1 - bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()

		elif next1 == A[0]:
			tmp = a_max - next1
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				#print(next1)
				print("No")
				sys.exit()

		else:
			tmp = next1 + bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
	print("No")


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
from operator import xor

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

if (n % 3 == 0) | (n % 2 == 0):
    uni = list(set(hats))
    count = [hats.count(uni[i]) for i in range(len(uni))]
    if (len(uni) in [2,3]) & len(set(count)) == 1:
        print(*(uni*count[0]))
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N == 3:
    print('No')
elif len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(set(a)) == 3:
        c = []
        for i in list(set(a)):
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3:
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# A
N = int(input())
a = list(map(int, input().split()))
flag = True
if N % 3  != 0:
    if max(a) == 0:
        print('Yes')
    else:
        print('No')
else:
    if N == 3:
        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')
    else:
        n = int(N / 3)
        a = sorted(a)
        for i in range(3):
            tmp_list = a[n * i : n * (i + 1)]
            if min(tmp_list) == max(tmp_list):
                pass
            else:
                flag = False
        if flag:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
input_num = [1,2,4,8]
input_num = [i for i in reversed(input_num)]
input_size = len(input_num)-1
print(input_num[input_size])

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
    if input_num[left]^input_num[right] == input_num[i]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

dic = defaultdict(int)

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

n = len(dic.keys())
cnts = dic.values()

if n == 3:
    print('Yes')
    
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = input().split(" ")
A = [int(i) for i in a]

bit = [A[0],A[1]]
flag = 0
num = 2
while flag == 0:
    k = 0
    flag2 = 0
    for i in range(len(bit)):
        if i == 0:
            b = bin(bit[0]^bit[len(bit)-1])[2::]
            if b == np.binary_repr(A[num]):
                k = i
                flag2 = 1
                break
        else:
            b = bin(bit[i-1]^bit[i])[2::]
            if b == np.binary_repr(A[num]):
                k = i
                flag2 = 1
                break
    if flag2 == 1:
        bit.insert(k, A[num])
        num += 1
        if num == N:
            flag = 1
    if flag2 == 0:
        print("No")
        break
if flag == 1:
    print("Yes")

Submission status: Wrong Answer

Solution code:
input()
input()
print('Yes')

Submission status: Wrong Answer

Solution code:
import collections
import random
n=int(input())
a=list(map(int,input().split()))
f=0
ct=0
C=collections.Counter(a)
D=C.most_common()
for i in range(n):
  if a[i]==0:
    ct=1
    f=1
for i in range(n):
  a[i]=format(a[i],'020b')
l=[0 for i in range(20)]
for i in range(n):
  for j in range(20):
    if a[i][j]=='1':
      l[j]+=1
for j in range(20):
  l[j]=l[j]%2

if f==0:
  if 1 in l:
    print('No')
  elif n%3!=0:
    print('No')
  else:
    x=random.randint(1,2)
    if x%2==0:
      print('No')
    else:
      print('Yes')
elif f==1:
  if len(D)==1:
    print('Yes')
  elif len(D)==2 and D[0][0]!=0 and D[0][1]==D[1][1]*2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math
 
N = int(input())
a = list(map(int, input().split(" ")))
 
def XOR(x):
	n = x.bit_length()
	count = 0
	while n > 0:
		count = count + x // int(math.pow(2,n-1))
		if x // int(math.pow(2,n-1)) == 1:
			x = x - int(math.pow(2,n-1))
		n = n - 1
	return count % 2
 
c_odd = 0
c_eve = 0
for i in range(N):
	if XOR(a[i])==1:
		c_odd = c_odd + 1
	else:
		c_eve = c_eve + 1
 
if N % 2 == 1:
	if c_odd == c_eve + 1 or c_odd == 0:
		print('Yes')
	else:
		print('No')
else:
	if c_odd == c_eve or c_odd == 0:
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

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

if 0 in a:
    print("Yes")
    exit()

if (a[0] ^ a[N-1]) in a:
    print("Yes")
    exit()

for i in range(N):
    for j in range(N):
        if (a[i] ^ a[j]) in a:
            print("Yes")
            exit()
        j += 1

print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N == 3:
    print('Yes')
elif len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(set(a)) == 3:
        c = []
        for i in list(set(a)):
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3:
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys,itertools,copy
input = sys.stdin.readline
N=int(input().strip())
an=[int(x) for x in input().strip().split()]

if N==3:
    if an[0]^an[1]==an[2]:
        print("Yes")
    else:
        print("No")
elif N%3!=0:
    if len(set(an))==1:
        print("Yes")
    else:
        print("No")
else:
    bn = list(set(an))
    if len(bn)>3:
        print("No")
    elif len(bn)==1:
        print("Yes")
    elif len(bn)==2:
        if bn.count(0)==1:
            print("Yes")
        else:
            print("No")
    elif bn[0]^bn[1]!=bn[2]:
        print("No")
    else:
        for b in bn:
            if an.count(b)%(N/3)!=0:
                print("No")
                break
        else:
            print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

def main():
    n = int(input())-1
    nums = list(map(int,input().split()))
    bins = []
    for num in nums:
        bins.append(int(bin(num)[2:]))

    #print(bins)
    #[1(0), 10(1), 100(2), 1000(3)]:No
    #[1(0), 10(1), 11(2)]:Yes
    if int(str(sum(bins)).replace("2","0")) == 0:
        print("Yes")
    elif int(str(sum(bins)).replace("2","0")) == 1:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
arr.sort()
if arr[0] == 1 and arr[1] == 2 and arr[2] == 3:
    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):
    if i == (N-1):
        b = a[i-1] ^ a[0]
        if a[i] != b:
            count += 1
            break
        break
    b = a[i-1] ^ a[i+1]
    if a[i] != b:
        count += 1
if count == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = [input() for i in range(2)]

N = int(a[0])
data = a[1].split(' ')

data = [int(i) for i in data]

result = []
for i in range(N):
    for j in range(N):
        if i <= j:
            continue
        result.append(data[i] ^ data[j])
        
sorted_data = data.sort()
sorted_result = result.sort()

if sorted_data == sorted_result:
    print('Yes')
    
print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a_uni = list(set(a))
if len(a_uni) == 1:
	if a[0] == 0:
		print("Yes")
elif n%3 != 0:
	print("No")
elif len(a_uni) == 2:
	if a.count(0) == n/3:
		print("Yes")	
	else:
		print("No")	
elif len(a_uni) == 3:
	if a.count(a[0])==n/3:
		if a.count(a[1])==n/3:
			print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N == 3:
    print(0)
elif len(set(a)) == 1 and a[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(set(a)) == 3:
        c = []
        for i in list(set(a)):
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3:
            print('Yes')
        else:
            print('No')
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
#入力
#a = int(input())
#b,c = map(int, input().split())
#s = input()

N = int(input())
s = input()
a = np.asarray(s.split(), dtype=int)

#処理

d = {}
for val  in a:
    if val in d.keys():
        d[val] += 1
    else:
        d[val] = 1

keyNum = len(d.keys())
num = len(a)
keys = list(d.keys())

#条件１
if len(d.keys()) == 1 and 0 in d.keys():
    print ("Yes")
elif len(a) % 3 != 0:
    print ("No")
elif keyNum == 2:
    keys.sort()
    if keys[0] != 0:
        print ("No")
    elif d[0] != num//3:
        print ("No")
    else:
        print ("Yes")
#        keys1 = format(keys[1],'b')
#        isAll1 = True
#        for x in keys1:
#            if x != '1':
#                isAll1 = False
#                break
#        if isAll1:
#            print ("Yes")
#        else:
#            print ("No")

elif keyNum != 3:
    print ("No")

else:
    key1 = format(keys[0],'099b')
    key2 = format(keys[1],'099b')
    key3 = format(keys[2],'099b')
    isA = True
    for k1,k2,k3 in zip(key1,key2,key3):
        kk1 = int(k1)
        kk2 = int(k2)
        kk3 = int(k3)
        goukei = kk1 + kk2 + kk3
        if not (goukei == 0 or goukei == 2):
            isA = False
            break
    
    if isA:
        print ("Yes")
    else:
        print ("No")

Submission status: Wrong Answer

Solution code:
def solve(N, _as):
    if N % 3 != 0:
        return False

    max_bit_len = 0
    max_bit_len_ints = []
    other_ints = []
    for a in _as:
        bl = int.bit_length(a)
        if bl > max_bit_len:
            max_bit_len = bl
            other_ints.extend(max_bit_len_ints)
            max_bit_len_ints.clear()
            max_bit_len_ints.append(a)
        elif bl == max_bit_len:
            max_bit_len_ints.append(a)
        else:
            other_ints.append(a)

    if N // 3 != len(other_ints):
        return False

    first = max_bit_len_ints.pop()
    for second in other_ints:
        ans = _solve(first, second, max_bit_len_ints, other_ints)
        if ans:
            return True
    return False


def _solve(first, second, _max_bit_len_ints, _other_ints):
    max_bit_len_ints = _max_bit_len_ints[:]
    other_ints = _other_ints[:]
    other_ints.remove(second)

    pre_latest = second
    latest = first^second
    try:
        max_bit_len_ints.remove(latest)
    except ValueError:
        return False

    count = 0
    while len(max_bit_len_ints) > 0 and len(other_ints) > 0:
        _latest = latest
        latest = pre_latest^latest
        pre_latest = _latest
        if count == 0 or count == 2:
            try:
                max_bit_len_ints.remove(latest)
            except ValueError:
                return False
        else:
            try:
                other_ints.remove(latest)
            except ValueError:
                return False
        count = (count + 1) % 3

    return pre_latest^latest == first and latest^first == second


if __name__ == '__main__':
    N = int(input())
    _as = [int(x) for x in input().split()]
    print('Yes' if solve(N, _as) else 'No')

Submission status: Wrong Answer

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

res = "No"
a_set = list(set(a))

a_set = [i for i in a_set if i != 0]

if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"

print(res)