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:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ac = Counter(A)

    if len(ac) == 1 and 0 in ac:
        return 'Yes'

    if N % 3 == 0 and len(ac) == 2 and 0 in ac and ac[0] == 2 * (N//3):
        return 'Yes'

    if N % 3 == 0 and len(ac) == 3:
        for v in ac.values():
            if v != N//3:
                break
        else:
            a = list(ac.keys())
            if a[0] ^ a[1] ^ a[2] ==  0:
                return 'Yes'

    return 'No'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ac = Counter(A)

    if len(ac) == 1 and 0 in ac:
        return 'Yes'
    if N % 3 == 0 and len(ac) == 2 and 0 in ac and ac[0] == 2 * (N//3):
        return 'Yes'

    if N % 3 == 0 and len(ac) == 3:
        for v in ac.values():
            if v != N//3:
                break
        else:
            return 'Yes'

    return 'No'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print("Yes" if A[0] ^ A[1] else "No")

Submission status: Wrong Answer

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

print("Yes" if A[0] == A[1] else "No")

Submission status: Wrong Answer

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

print("Yes" if A[-1] == A[0] else "No")

Submission status: Wrong Answer

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

print("Yes" if A[-1] == A[0] and A[-1] == A[0] else "No")

Submission status: Wrong Answer

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

print("YES" if A[-1] == A[0] and A[-1] == A[0] else "NO")

Submission status: Wrong Answer

Solution code:
import collections

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

# 条件1 全部0だったらOK
if all(i == 0 for i in a):
    flag = 1
# 条件2 2*3/Nがxが書かれていて、残りは0ならOK これは0の個数確定＋二種の数字で確定できる。
elif N % 3 == 0 and len(b) == 2 and b['0'] == N // 3:
    flag = 1
# 条件3 xとyとzのXORをとり、それが0となるような3つの相違なる整数がN/3存在
elif N % 3 == 0 and len(b) == 3:
    # 連想配列のキーとなる数（数字の種類をリスト化）
    k = list(b.keys())
    if k[0] ^ k[1] ^ k[2] == 0 and all(i == N / 3 for i in k):
        flag = 1

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

Submission status: Wrong Answer

Solution code:
import collections

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

# 条件1 全部0だったらOK
if all(i == 0 for i in a):
    flag = 1
# 条件2 2*3/Nがxが書かれていて、残りは0ならOK これは0の個数確定＋二種の数字で確定できる。
elif N % 3 == 0 and len(b) == 2 and b['0'] == N // 3:
    flag = 1
# 条件3 xとyとzのXORをとり、それが0となるような3つの相違なる整数がN/3存在
elif N % 3 == 0 and len(b) == 3:
    # 連想配列のキーとなる数（数字の種類をリスト化）
    k = list(b.keys())
    if k[0] ^ k[1] ^ k[2] == 0:
        flag = 1

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

Submission status: Wrong Answer

Solution code:
import collections

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

# 条件1 全部0だったらOK
if all(i == 0 for i in a):
    flag = 1
# 条件2 2*3/Nがxが書かれていて、残りは0ならOK これは0の個数確定＋二種の数字で確定できる。
elif N % 3 == 0 and len(b) == 2 and b['0'] == N // 3:
    flag = 1
# 条件3 xとyとzのXORをとり、それが0となるような3つの相違なる整数がN/3存在
elif N % 3 == 0 and len(b) == 3 and b[0] ^ b[1] ^ b[2] == 0:
    flag = 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
num = list(map(int,input().split()))
c = True
lim = 10 ** 6
nn = num[-1::lim]+num+num[0::lim]
for i in range(1,N+1):
  if (nn[i-1] ^ nn[i+1]) != nn[i]:
    c = False
    break
if c:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = list(map(int, input().split()))
#set型にしてからlistにキャストすることで，複数存在するものを省いている
unq = list(set(nums))

#違う数字が4個以上存在したら，正しい答えは存在しない
if len(unq) > 3:
  print("No")

if len(unq) == 3:
    #list,unqをアンパックしてa,b,cにいれている
    a,b,c = unq
    if a ^ b ^ c != 0:
      if nums.count(a) == nums.count(b) == nums.count(c):
        print("Yes")
      else:
        print("No")
    else:
      print("No")

if len(unq) == 2:
    a,b = sorted(unq)
    if a == 0:
      if nums.count(a) * 2 == nums.count(b):
        print("Yes")
      else:
        print("No")
    else:
      print("No")

if len(unq) == 1:
    a = unq[0]
    if a != 0:
      print("No")
    else:
      print("Yes")

Submission status: Wrong Answer

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

if N%3:
    print('No')
    exit()

from collections import Counter
C = Counter(A)
if len(C) > 3:
    print('No')
    exit()

if len(C) == 1:
    print('Yes' if A[0]==0 else 'No')
elif len(C) == 2:
    if C[0] != N//3:
        print('No')
    else:
        print('Yes')
else:
    if any(v!=N//3 for v in C.values()):
        print('No')
    else:
        a,b,c = list(C)
        print('Yes' if a^b == c else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
elif len(C)==3:
	a,b,c=C.keys()
	na,nb,nc=C.values()
	if a^b==c and na==nb==nc:
		print "Yes"
		quit()
elif len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		a,b=L[0][0],L[1][0]
		na,nb=L[0][1],L[1][1]
		if a==0 and na==N/3:
			print"Yes"
			quit()

else:
	print "No"


print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
elif len(C)==3:
	a,b,c=C.keys()
	na,nb,nc=C.values()
	if a^b==c and na==nb==nc:
		print "Yes"
		quit()
elif len(C)==2:
	L=C.items()
	L.sort()
	a,b=L[0][0],L[1][0]
	na,nb=L[0][1],L[1][1]
	if a==0 and na==N/3:
		print"Yes"
		quit()

else:
	print "No"


print "No"

Submission status: Wrong Answer

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

if N%3:
    print('No')
    exit()

from collections import Counter
C = Counter(A)
if len(C) > 3:
    print('No')
    exit()

if len(C) == 1:
    print('Yes' if A[0]==0 else 'No')
elif len(C) == 2:
    if 0 not in C:
        print('No')
    elif C[0] != N//3:
        print('No')
    else:
        print('Yes')
else:
    if any(v!=N//3 for v in C.values()):
        print('No')
    else:
        a,b,c = list(C)
        print('Yes' if a^b == c else 'No')

Submission status: Wrong Answer

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

b = list(set(a))
c = [0]*len(b)

if len(b)>3:
    print('No')
    exit()

if n%3!=0:
    if len(b)==1 and b[0]==0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

for i in range(n):
    for j in range(len(b)):
        if a[i]==b[j]:
            c[j]+=1
            break

if len(b)==1:
    if b[0]^b[0]==b[0]:
        print('Yes')
        exit()
elif len(b)==2:
    if c[0]==n*2//3:
        if b[0]^b[0]==b[1] and b[0]^b[1]==b[0]:
            print('Yes')
            exit()
    elif c[1]==n*2//3:
        if b[1]^b[1]==b[0] and b[0]^b[1]==b[1]:
            print('Yes')
            exit()
elif len(b)==3:
    if b[0]^b[1]==b[2] and b[1]^b[2]==b[0] and b[2]^b[0]==b[1]:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
elif len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
			quit()
elif len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		print L
		if L[0][0]==0 and L[0][1]==N/3:
			print "Yes"
			quit()
else:
	print "No"


print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
	else:
		print "No"
elif len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
			quit()
	print "No"
elif len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		print L
		if L[0][0]==0 and L[0][1]==N/3:
			print "Yes"
			quit()
	print "No"		
else:
	print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
elif len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
			quit()
	print "No"
elif len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		print L
		if L[0][0]==0 and L[0][1]==N/3:
			print "Yes"
			quit()
	print "No"		
else:
	print "No"

Submission status: Wrong Answer

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

b = list(set(a))
c = [0]*len(b)

for i in range(n):
    for j in range(len(b)):
        if a[i]==b[j]:
            c[j]+=1
            break

if n%3!=0:
    if len(b)==0 and b[0]==0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

if len(b)==1:
    if b[0]^b[0]==b[0]:
        print('Yes')
        exit()
elif len(b)==2:
    if c[0]==n*2//3:
        if b[0]^b[0]==b[1] and b[0]^b[1]==b[0]:
            print('Yes')
            exit()
    elif c[1]==n*2//3:
        if b[1]^b[1]==b[0] and b[0]^b[1]==b[1]:
            print('Yes')
            exit()
elif len(b)==3:
    if b[0]^b[1]==b[2] and b[1]^b[2]==b[0] and b[2]^b[0]==b[1]:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
if len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
			quit()
	print "No"
if len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		print L
		if L[0][0]==0 and L[0][1]==N/3:
			print "Yes"
			quit()
	print "No"		
else:
	print "No"

Submission status: Wrong Answer

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

b = list(set(a))

if len(b)==3:
    if b[0]^b[1]==b[2] and b[1]^b[2]==b[0] and b[2]^b[0]==b[1]:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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


def main():
    from collections import Counter

    n = int(input())
    a = Counter(map(int, input().split()))
    key_count = len(a.keys())
    keys_values = a.most_common()

    if key_count == 1:
        if keys_values[0][0] == 0:
            print('Yes')
        else:
            print('No')
    elif key_count == 2:
        if keys_values[0][0] == 0 or keys_values[1][0] == 0:
            if n % 3 == 0:
                if keys_values[1][0] == 0:
                    if keys_values[0][1] // keys_values[1][1] == 2:
                        print('Yes')
                    else:
                        print('No')
                elif keys_values[0][0] == 0:
                    if keys_values[1][1] // keys_values[0][1] == 2:
                        print('Yes')
                    else:
                        print('No')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    elif key_count == 3:
        if keys_values[0][1] == keys_values[1][1] == keys_values[2][1]:
            xors = keys_values[0][0] ^ keys_values[1][0] ^ keys_values[2][0]

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    from collections import Counter

    n = int(input())
    a = Counter(map(int, input().split()))
    key_count = len(a.keys())
    keys_values = a.most_common()

    if key_count == 1:
        if keys_values[0][0] == 0:
            print('Yes')
        else:
            print('No')
    elif key_count == 2:
        if keys_values[0][0] == 0 or keys_values[1][0] == 0:
            if n % 3 == 0:
                if keys_values[1][0] == 0:
                    if keys_values[0][1] // keys_values[1][1] == 2:
                        print('Yes')
                    else:
                        print('No')
                elif keys_values[0][0] == 0:
                    if keys_values[1][1] // keys_values[0][1] == 2:
                        print('Yes')
                    else:
                        print('No')
            else:
                print('No')
        else:
            print('No')
    elif key_count == 3:
        if keys_values[0][1] == keys_values[1][1] == keys_values[2][1]:
            xors = keys_values[0][0] ^ keys_values[1][0] ^ keys_values[2][0]

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    from collections import Counter

    n = int(input())
    a = Counter(map(int, input().split()))
    key_count = len(a.keys())
    keys_values = a.most_common()

    if key_count == 1:
        if keys_values[0][0] == 0:
            print('Yes')
        else:
            print('No')
    elif key_count == 2:
        if keys_values[0][0] == 0 or keys_values[1][0] == 0:
            if n % 3 == 0:
                if keys_values[0][1] // keys_values[1][1] == 2 or keys_values[1][1] // keys_values[0][1] == 2:
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    elif key_count == 3:
        if keys_values[0][1] == keys_values[1][1] == keys_values[2][1]:
            xors = keys_values[0][0] ^ keys_values[1][0] ^ keys_values[2][0]

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
			quit()
	print "No"
if len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		if L[0][0]==0 and L[0][1]==N/3:
			print "Yes"
			quit()
	print "No"		
else:
	if len(C)==1:
		if C.keys()==[0]:
			print "Yes"
			quit()
	print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
			quit()
	print "No"
else:
	if len(C)==1:
		if C.keys()==[0]:
			print "Yes"
			quit()
	print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
		else:
			print "No"
	else:
		print "No"
else:
	if len(C)==1:
		if C.keys()==[0]:
			print "Yes"
		else:
			print "No"
	else:
		print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)==3:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
		else:
			print "No"
else:
	if len(C)==1:
		if C.keys()==[0]:
			print "Yes"
		else:
			print "No"
	else:
		print "No"

Submission status: Wrong Answer

Solution code:
import collections

YES="Yes"
NO="No"

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

c = collections.Counter(a)
l_c = len(c)
if l_c == 1:
    if c[0] == N:
        print(YES)
    else:
        print(NO)
elif l_c == 3:
    v = list(c.values())
    if v[0] == v[1] == v[2]:
        print(YES)
    else:
        print(NO)
else:
    print(NO)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ac = Counter(A)
    if N % 3 != 0:
        return 'No'
    if len(ac) != 3:
        return 'No'
    for v in ac.values():
        if v != N//3:
            return 'No'
    a = list(ac.keys())
    if a[0] ^ a[1] != a[2] or a[1] ^ a[2] != a[0]:
        return 'No'

    return 'Yes'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ac = Counter(A)
    print(len(ac))
    if N % 3 != 0:
        return 'No'
    if len(ac) != 3:
        return 'No'
    for v in ac.values():
        if v != N//3:
            return 'No'
    a = list(ac.keys())
    if a[0] ^ a[1] != a[2] or a[1] ^ a[2] != a[0]:
        return 'No'

    return 'Yes'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ac = Counter(A)
    if N % 3 != 0:
        return 'No'
    if len(ac) != 3:
        return 'No'
    for v in ac.values():
        if v != N//3:
            return 'No'
    return 'Yes'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
if N % 3:
  print('No')
else:
  a.sort()
  M = N//3
  if a[0]^a[M]^a[2*M] != 0:
    print('No')
  else:
    for i in range(N):
      if a[i] != a[(i//M)*M]:
        print('No')
        break
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import collections


input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    c = collections.Counter(a)
    s = list(c.keys())
    v = list(c.values())
    if (len(c) == 3) and (s[0] == s[1] ^ s[2]) and (v[0] == v[1] == v[2]):
        print("Yes")
    elif len(c) == 1 and s[0] == 0:
        print("Yes")
    elif len(c) == 2 and 0 in s and (c[0] == n/3*2):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil

from sys import exit

from copy import deepcopy

def main():


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

    if len(aunique) == 1:
        if a[0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(aunique) is 2:
        if n%3 or not 0 in aunique:
            print("No")
        else:
            l = []
            l.append(a.count(aunique[0]))
            l.append(a.count(aunique[1]))
            if aunique[0] == 0:
                if not l[0] == n//3:
                    print("No")
                else:
                    print("Yes")
            else:
                if not l[1] == n//3:
                    print("No")
                else:
                    print("Yes")
    elif len(aunique) is 3 and not n%3:
        l = []
        l.append(a.count(aunique[0]))
        l.append(a.count(aunique[1]))
        l.append(a.count(aunique[2]))

        if not l[0] is n//3 or not l[1] is n//3:
            print("No")
        else:
            if (aunique[0] ^ aunique[1]) ^ aunique[2] ==0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")



main()

Submission status: Wrong Answer

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil

from sys import exit

from copy import deepcopy

def main():


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

    if len(aunique) == 1:
        if a[0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(aunique) is 2:
        if n%3 or not 0 in aunique:
            print("No")
        else:
            l = []
            l.append(a.count(aunique[0]))
            l.append(a.count(aunique[1]))
            if aunique[0] == 0:
                if not l[0] == n//3:
                    print("No")
                else:
                    print("Yes")
            else:
                if not l[1] == n//3:
                    print("No")
                else:
                    print("Yes")


    elif len(aunique) > 3 or n%3:
        print("No")
    else:
        l = []
        l.append(a.count(aunique[0]))
        l.append(a.count(aunique[1]))
        l.append(a.count(aunique[2]))

        if not l[0] is n//3 or not l[1] is n//3:
            print("No")
        else:
            if (aunique[0] ^ aunique[1]) ^ aunique[2] ==0:
                print("Yes")
            else:
                print("No")



main()

Submission status: Wrong Answer

Solution code:

N = int(input())

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

isPuttable = True

for i in range(0, N):
  if a[i] != (a[(i-1)%N] ^ a[(i+1)%N]):
    isPuttable = False
    
if isPuttable:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:

N = int(input())

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

isPuttable = True

for i in range(0, N):
  if a[i] != (a[(i-1)%N] ^ a[(i+1)%N]):
    isPuttable = False
    
if isPuttable:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
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"
if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set:
        if N%3 == 1 and a.count(0) == N/3:
            res = "Yes"
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
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"
if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set and a.count(a_set[0]) == a.count(a_set[1]):
        res = "Yes"
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
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"
if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set:
        res = "Yes"
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
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"
if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
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"
if len(a_set) == 0:
    if a_set[0] == 0:
        res = "Yes"
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for i in input().split():
  i = int(i)
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

if 0 in d and d[0] == n:
  print('Yes')
elif len(d.keys()) == 2 and n%3 == 0 and 0 in d and d[0] == n//3:
  print('Yes')
elif len(d.keys()) == 3 and n%3 == 0:
  x = 0
  for i in d.keys():
    x ^= i
    if d[i] != n//3:
      print('No')
  if x == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for i in input().split():
  i = int(i)
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

if 0 in d and d[0] == n:
  print('Yes')
elif len(d.keys()) == 2 and 0 in d and d[0] == n//3:
  print('Yes')
elif len(d.keys()) == 3:
  x = 0
  for i in d.keys():
    x ^= i
    if d[i] != n//3:
      print('No')
  if x == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')