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 collections

keta_max = 30
def decimal_to_binary(number):
    ans = ""
    for i in range(keta_max):
        ans += str(number // 2**(keta_max - 1 - i))
        number = number % 2**(keta_max - 1 - i)
    return ans

def distance(left, right):
    ans = 0
    for i in range(keta_max):
        if(abs(int(left[i]) - int(right[i]))):
            ans += 2**(keta_max - 1 - i)
    return ans

def step(index, not_used_hat_set, current_hat_list):
    print(not_used_hat_set)
    for j in not_used_hat_set:
        if(distance_map[index-1][j] == index+1):
            current_hat_list[index] = j + 1
            if(index == N - 1):
                return True
            else:
                step(index + 1, not_used_hat_set - set([j + 1]), current_hat_list)
    return False

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

bynary_list = [decimal_to_binary(i) for i in a_list]
distance_map = collections.Counter()
for n in range(N):
    tmp = [distance(bynary_list[n], bynary_list[m]) for m in range(N)]
    distance_map[n+1] = tmp

for n in range(N):
    hat = [0 for m in range(N)]
    not_used_hat_set = set([m for m in range(N)])
    hat[0] = (n+1)%N
    hat[1] = (n+2)%N
    not_used_hat_set = not_used_hat_set - set([n, (n+1)%N])
    ans = step(2, not_used_hat_set, hat)
    if(ans == True):
        break
if(ans == True):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if 0 in A:
  if len(set(A)) == 1:
    print("Yes")
    exit()
  elif len(set(A)) == 2:
    if A.count(0) *2 == (len(A)-A.count(0)):
      print("Yes")
      exit()
elif len(set(A)) == 3:
  temp =  list(set(A))
  if A.count(temp[0]) == A.count(temp[1]) == A.count(temp[2]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

if 0 in A:
  if len(set(A)) == 2:
    if A.count(0) *2 == (len(A)-A.count(0)):
      print("Yes")
      exit()
elif len(set(A)) == 3:
  temp =  list(set(A))
  if A.count(temp[0]) == A.count(temp[1]) == A.count(temp[2]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
flag = True
for i in range(N-1):
  if(a[-1+i]^a[i+1] != a[i]):
    flag = False
    break;
if(a[N-2]^a[0] != a[N-1]):
  flag = False
if(flag):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif N%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1] and l[int(N/3 - 1)] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1]^k[2] == 0:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if N%3 == 0:
    if len(lset) == 1:
        if l[0] == 0:
            print("Yes")
        else:
            print("No")
            
    if len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1] and l[int(N/3 - 1)] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

else:
    if len(lset) == 1:
        if l[0] == 0:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif N%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1] and l[int(N/3 - 1)] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif N%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1]:
            for i in l:
                c = 0
                if i == k[0]:
                    c += 1
            if c == N/3:
                print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif len(l)%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1] and l[int(N/3 - 1)] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif len(l)%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1]:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            if l[int(N/3)] == k[1] and l[int(2*N/3)] == k[2]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif len(l)%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1]:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        if k[0]^k[1] == k[2] and l[int(N/3)] == k[1] and l[int(2*N/3)] == k[2]:
            print("Yes")
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

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

set_inputs = set(inputs)
if N % 3 == 0:
    list_inputs = list(set_inputs)
    if (len(set_inputs) == 3 
    and list_inputs[0] == (list_inputs[1] ^ list_inputs[2]) 
    and (inputs.count(list_inputs[0]) == inputs.count(list_inputs[1]) == inputs.count(list_inputs[2]))):
        print('Yes')
    elif len(set_inputs) == 2:
        list_inputs = list(set_inputs)
        if inputs.count(list_inputs[0]) > inputs.count(list_inputs[1]):
            more = list_inputs[0]
            less = list_inputs[1]
        else:
            more = list_inputs[1]
            less = list_inputs[0]
        if less == 0 and inputs.count(more) == inputs.count(less) * 2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if set_inputs == set([0]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

set_inputs = set(inputs)
if N % 3 == 0:
    list_inputs = list(set_inputs)
    if len(set_inputs) == 3 and list_inputs[0] == (list_inputs[1] ^ list_inputs[2]) and (inputs.count(list_inputs[0]) == inputs.count(list_inputs[1]) == inputs.count(list_inputs[2])):
        print('Yes')
    else:
        print('No')
else:
    if set_inputs == set([0]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

set_inputs = set(inputs)
if N % 3 == 0:
    list_inputs = list(set_inputs)
    if len(set_inputs) == 3 and list_inputs[0] == (list_inputs[1] ^ list_inputs[2]):
        print('Yes')
    else:
        print('No')
else:
    if set_inputs == set([0]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
listA=list(map(int,input().split()))
listA.sort()
for i in range(N):
  if i==N-1:
    a=listA[i-1]
    b=listA[0]
  else:
    a=listA[i-1]
    b=listA[i+1]
  ans=int(a^b)
  if ans!=listA[i]:
    print("No")
    sys.exit()
if len(set(listA))!=1:
  print("No")
  sys.exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in range(N):
    sum ^= a[i]

    print('Yes' if sum == 0 else 'No')

Submission status: Wrong Answer

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

if N % 3 == 0:
    if len(B) == 1 and B[0] == 0:
        print('Yes')
        exit()
    if len(B) == 2 and A.count(0) == N // 3:
        print('Yes')
        exit()
    if len(B) == 3 and A.count(B[0]) == A.count(B[1]) == A.count(B[2]):
        if B[0] ^ B[1] ^ B[2] == 0:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = sorted(set(A))
if N % 3 == 0:
    if len(B) == 1 and B[0] == 0:
        print('Yes')
        exit()
    if len(B) == 2 and A.count(0) == N // 3 and A.count(B[1]) == 2 * N // 3:
        print('Yes')
        exit()
    if len(B) == 3 and A.count(B[0]) == A.count(B[1]) == A.count(B[2]):
        if B[0] ^ B[1] ^ B[2] == 0:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = sorted(set(A))
if N % 3 == 0:
    if len(B) == 1 and B[0] == 0:
        print('Yes')
        exit()
    if len(B) == 2 and A.count(0) == N // 3 and A.count(B[1]) == 2 * N // 3:
        print('Yes')
        exit()
    if len(B) == 3 and A.count(B[0]) == A.count(B[1]) == A.count(B[2]):
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

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

def yes():
    S = set(A)
    if A.count(0) == N:
        return True
    if N % 3 != 0:
        return False
    if len(S) == 3:
        a, b, c = tuple(S)
        return any(A.count(x) == N // 3 for x in S) and a ^ b == c
    if len(S) == 2:
        a, b = tuple(S)
        return (a == 0 or b == 0) and A.count(0) == N // 3

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

Submission status: Wrong Answer

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

def yes():
    S = set(A)
    if A.count(0) == N:
        return True
    if N % 3 != 0 or len(S) != 3 or any(A.count(x) != N // 3 for x in S):
        return False
    a, b, c = tuple(S)
    return a ^ b == c

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

Submission status: Wrong Answer

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

for i in range(n):
    if i==0:
        if a[n-1]^a[1] != a[0]:
            print("No")
            sys.exit()
    elif 0 < i < n-1:
        if a[i-1]^a[i+1] != a[i]:
            print("No")
            sys.exit()
    elif i == n-1:
        if a[n-2]^a[0] != a[n-1]:
            print("No")
            sys.exit()
print("Yes")

Submission status: Wrong Answer

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

for i in range(n):
    if i==0:
        if a[n-1]^a[i+1] != a[i]:
            print("No")
            sys.exit()
    elif 0 < i < n-1:
        if a[i-1]^a[i+1] != a[i]:
            print("No")
            sys.exit()
    elif i == n-1:
        if a[i-1]^a[0] != a[i]:
            print("No")
            sys.exit()
print("Yes")

Submission status: Wrong Answer

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

if n == 3:
    ans = True
    ans = ans and (a[0] ^ a[2] == a[1])
    ans = ans and (a[1] ^ a[0] == a[2])
else:
    ans = True
    for i in range(n - 1):
        ans = ans and (a[i] == a[i + 1])
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N%3==0:
	k = N//3
	flg = 0
	x1, x2, x3 = -1, -1, -1
	if a[0]==a[k-1]:
		x1 = a[0]
		flg +=1
	if a[k]==a[2*k-1]:
		x2 = a[k]
		flg +=1
	if a[2*k]==a[3*k-1]:
		x3 = a[2*k]
		flg +=1
	if flg == 3:
		if (x1^x2)==x3 and (x2^x3)==x1 and (x3^x1)==x2:
			print("Yes")
		else:
			print("No")
	else:
		print("No")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    a = [int(s) for s in input().split() if s]
    flag = True
    for i in range(N):
        first = (i-1)%N
        second = (i+1)%N
        if a[i] != a[first]^a[second]:
            flag = False
    print('Yes' if flag else 'No')

solve()

Submission status: Wrong Answer

Solution code:
from sys import*
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
for i in range(n):
    if a[i] != i + 1:
        print("No")
        exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
nn = map(int, raw_input().split())
nn = nn[0]
aa = map(int, raw_input().split())

def solve(n,a):
	all_zero = True
	for number in a:
		if number != 0:
			all_zero = False
			break

	if all_zero:
		print 'Yes'
		return

	a_dict = {}
	for number in a:
		if number in a_dict.keys(): 
			a_dict[number] += 1
		else:
			a_dict[number] = 1
	if len(a_dict.keys()) > 3:
		print 'No'
		return
	

	if len(a_dict.keys()) == 3:
		for keys in a_dict.keys():
			if not a_dict[keys] == n // 3:
				print 'No'
				return
		
		print 'Yes'
		return


	if len(a_dict.keys()) == 2:
		if not 0 in a_dict.keys():
			print 'No'
			return
		for keys in a_dict.keys():
			if keys == 0:
				if not a_dict[keys] == n // 3:
					print 'No'
					return
			else: 
				if not a_dict[keys] == 2 * n // 3:
					print 'No'
					return
	print 'Yes'
	return


solve(nn, aa)

Submission status: Wrong Answer

Solution code:
nn = map(int, raw_input().split())
nn = nn[0]
aa = map(int, raw_input().split())

def solve(n,a):
	all_zero = True
	for number in a:
		if number != 0:
			all_zero = False
			break

	if all_zero:
		print 'Yes'
		return

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

	if len(a_dict.keys()) > 3:
		print 'No'
		return

	if len(a_dict.keys()) == 3:
		result = True
		for keys in a_dict.keys():
			if not a_dict[keys] == n // 3:
				result = False
				break
		if result:
			print 'Yes'
			return


	if len(a_dict.keys()) == 2:
		if not '0' in a_dict.keys():
			print 'No'
			return
		for keys in a_dict.keys():
			if keys == 0:
				if not a_dict[keys] == n // 3:
					print 'No'
					return
			else: 
				if not a_dict[keys] == 2 * n // 3:
					print 'No'
					return
	print 'Yes'
	return

solve(nn,aa)

Submission status: Wrong Answer

Solution code:
nn = map(int, raw_input().split())
nn = nn[0]
aa = map(int, raw_input().split())

def solve(n,a):
	all_zero = True
	for number in a:
		if number != 0:
			all_zero = False
			break

	if all_zero:
		print 'Yes'
		return

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

	if len(a_dict.keys()) > 3:
		print 'No'
		return

	if len(a_dict.keys()) == 3:
		result = True
		for keys in a_dict.keys():
			if not a_dict[keys] == n // 3:
				result = False
				break
		if result:
			print 'Yes'


	if len(a_dict.keys()) == 2:
		if not '0' in a_dict.keys():
			print 'No'
			return
		for keys in a_dict.keys():
			if keys == 0:
				if not a_dict[keys] == n // 3:
					print 'No'
					return
			else: 
				if not a_dict[keys] == 2 * n // 3:
					print 'No'
					return
	print 'Yes'

solve(nn,aa)

Submission status: Wrong Answer

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

for i in range(N):
    temp ^= a[i]

if temp == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

for i in range(N):
    temp ^= a[i]

if temp^temp == temp:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if c == 0:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if aa * bb * cc == 0:
  print('Yes')

Submission status: Wrong Answer

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

for i in range(N):
    temp = temp ^ a[i]

if temp^temp == temp:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n = int(input())
if n > 1000:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
if n % 3 == 0:
  print('Yes')

Submission status: Wrong Answer

Solution code:
print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = a[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [[-1,0],[-1,0],[-1,0]]
flag = 0
for i in range(n):
  x = a[i]
  for j in range(3):
    if l[j] == [-1,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [[-1,0],[-1,0],[-1,0]]
flag = 0
for i in range(n):
  x = a[i]
  for j in range(3):
    if l[j] == [-1,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 0
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [[-1,0],[-1,0],[-1,0]]
flag = 0
for i in range(n):
  x = a[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 0
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = a[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 0
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
print(a)
for i in range(-1, int(N-1)):
  if a[i-1] ^ a[i+1] != a[i]:
    print("No")
    exit()
print("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] == 0:
                        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:
        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] == 0:
                        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')