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

input = sys.stdin.readline


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

    xor_all = 0
    zero_cnt = 0
    for a in A:
        xor_all = xor_all ^ a
        zero_cnt += 1 if a == 0 else 0

    if xor_all == 0 and zero_cnt * 2 == N - zero_cnt:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    xor_all = 0
    for a in A:
        xor_all = xor_all ^ a
    
    ans = "Yes" if xor_all == 0 else "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy

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

g0 = []
g1 = []
g_tmp = []
cnt_g = 0

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    while True:
        cnt = 0
        if all((a[i] == 0 for i in range(n))):
            print('Yes')
            exit()
        for i in range(n):
            if a[i] % 2 == 0:
                cnt += 1
                if cnt_g == 0:
                    g0.append(i)
                else:
                    g_tmp.append(i)
            a[i] //= 2
        if cnt * 3 != n:
            print('No')
            exit()
        if cnt_g == 0:
            cnt_g += 1
        elif cnt_g == 1:
            if g0 == g_tmp:
                pass
            else:
                g1 = copy.deepcopy(g_tmp)
                cnt_g += 1
        else:
            if g0 == g_tmp:
                pass
            elif g1 == g_tmp:
                pass
            else:
                print('No')
                exit()

Submission status: Wrong Answer

Solution code:
import copy

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

g0 = []
g1 = []
g_tmp = []
cnt_g = 0

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    while True:
        cnt = 0
        if all((a[i] == 0 for i in range(n))):
            print('Yes')
            exit()
        for i in range(n):
            if a[i] % 2 == 0:
                cnt += 1
                if cnt_g == 0:
                    g0.append(i)
                else:
                    g_tmp.append(i)
            a[i] //= 2
        if cnt * 3 != n:
            print('No')
            exit()
        if cnt_g == 0:
            cnt_g += 1
        elif cnt_g == 1:
            if g0 == g_tmp:
                pass
            else:
                g1 = copy.copy(g_tmp)
                cnt_g += 1
        else:
            if g0 == g_tmp:
                pass
            elif g1 == g_tmp:
                pass
            else:
                print('No')
                exit()

Submission status: Wrong Answer

Solution code:
import copy

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

g0 = []
g1 = []
g2 = []
g_tmp = []
cnt_g = 0

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    while True:
        cnt = 0
        if all((a[i] == 0 for i in range(n))):
            print('Yes')
            exit()
        for i in range(n):
            if a[i] % 2 == 0:
                cnt += 1
            if cnt_g == 0:
                g0.append(i)
            else:
                g_tmp.append(i)
            a[i] //= 2
        if cnt * 3 != n:
            print('No')
            exit()
        if cnt_g == 0:
            cnt_g += 1
        elif cnt_g == 1:
            if g0 == g_tmp:
                pass
            else:
                g1 = copy.copy(g_tmp)
                cnt_g += 1
        else:
            if g0 == g_tmp:
                pass
            elif g1 == g_tmp:
                pass
            else:
                print('No')
                exit()

Submission status: Wrong Answer

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

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    while True:
        cnt = 0
        if all((a[i] == 0 for i in range(n))):
            print('Yes')
            exit()
        for i in range(n):
            if a[i] % 2 == 0:
                cnt += 1
            a[i] //= 2
        if cnt * 3 != n:
            print('No')
            exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  d = Counter(a)

  if d[0] == n:
    return True
  if n % 3 != 0:
    return False
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3:
    if not all(v % 3 == 0 for v in d.values()):
      return False
    x,y,z = d.keys()
    if x ^ y ^ z == 0:
      return True
  return False





def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  d = Counter(a)

  if d[0] == n:
    return True
  if n % 3 != 0:
    return False
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3:
    x,y,z = d.keys()
    if x ^ y ^ z == 0:
      return True
  return False





def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  d = Counter(a)

  if all(not x for x in a):
    return True
  if n % 3 != 0:
    return False
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3 and all(value == n // 3 for value in d.values()):
    return True
  return False





def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  d = Counter(a)

  if d[0] == n:
    return True
  if n % 3 != 0:
    return False
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3 and all(value == n // 3 for value in d.values()):
    return True
  return False





def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  d = Counter(a)

  if d[0] == n:
    return True
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3 and all(value == n // 3 for value in d.values()):
    return True
  return False





def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  a = sorted(a)
  return all(a[i] ^ a[(i+2)%n] == a[(i+1)%n] for i in range(n))



def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
N = int(input())
num = list(map(int,input().split()))
a = 0
for i in num:
    a = a^i
if a == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=0
for i in a:
  b^=i
if b==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
A.sort()
ans='No'

now=A[0]
for a in A[1:]:
    now^=a
if now==0:
    ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
A.sort()
ans='No'

if all(a==0 for a in A):
    ans='Yes'

if N%3==0:
    if len(set(A))==0:
        if all(a==0 for a in A[:N//3]):
            ans='Yes'

if N%3==0:
    if len(set(A))==3:
        now=A[0]
        for a in A[1:]:
            now^=a
        if now==0:
            ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
L = [0]*(n+1)
for i in range(n):
    if i == 0:
        t = a[1]^a[-1]
    elif i == n-1:
        t = a[n-2]^a[0]
    else:
        t = a[i-1]^a[i+1]
    if 0 <= t <= n:
        L[t] += 1

sw = 1
for i in range(1,n+1):
    if L[i] != 1:
        sw = 0
        break
print(["No","Yes"][sw])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
if n%3 != 0:
    if a.count(0) == n:
        print("Yes")
    else:
        print("No")

    exit()

x,y,z = a[0],a[1],a[2]
if x^y != z:
    print("No")
else:
    for i in range(0,n,3):
        if x == a[i] and y == a[i+1] and z == a[i+2]:
            continue
        print("No")
        exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
now = 0
for i in a:
    now ^= i
if now:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = list(set(a))
n = len(l)
if n == 3:
    if l[0] ^ l[1] ^ l[2] == 0:
        x = a.count(l[0])
        y = a.count(l[1])
        z = a.count(l[2])
        if x == y == z:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n == 2:
    z = -1
    if l[0] == 0:
        x = 1
        z = 0
    if l[1] == 0:
        x = 0
        z = 1
    if z != -1:
        x = a.count(l[x])
        z = a.count(l[z])
        if x + x == z:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n == 1:
    if l[0] == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    x = al[i-1] ^ al[i+1]
    if x == al[i]:
        continue
    else:
        print('No')
        exit()

if not al[-1] ^ al[1] == al[0]:
    print('No')
elif not al[-2] ^ al[0] == al[-1]:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    x = al[i-1] ^ al[i+1]
    if x == al[i]:
        continue
    else:
        print('No')
        exit()

if not al[-1] ^ al[1] == al[0]:
    print('N0')
elif not al[-2] ^ al[0] == al[-1]:
    print('N0')
else:
    print('Yes')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    x = al[i-1] ^ al[i+1]
    if x == al[i]:
        continue
    else:
        print('No')
        exit()

if al[-1] ^ al[1] == al[0]:
    pass
else:
    print('N0')
    exit()
if al[-2] ^ al[0] == al[-1]:
    pass
else:
    print('N0')
    exit()
print('Yes')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    x = al[i-1] ^ al[i+1]
    if x == al[i]:
        continue
    else:
        print('No')
        exit()

if al[-1] ^ al[1] == al[0]:
    pass
else:
    print('N0')
if al[-2] ^ al[0] == al[-1]:
    pass
else:
    print('N0')
print('Yes')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    x = al[i-1] ^ al[i+1]
    if x == al[i]:
        continue
    else:
        print('No')
        exit()

if al[-1] ^ al[1] == al[0]:
    pass
elif al[-2] ^ al[0] == al[-1]:
    pass
else:
    print('N0')
print('Yes')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    x = al[i-1] ^ al[i+1]
    if x == al[i]:
        continue
    else:
        print('No')
        exit()

if al[-1] ^ al[1] == al[0]:
    pass
elif al[-2] ^ al[0] == al[1]:
    pass
else:
    print('N0')
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(A)

try:
    if cnt[0] == N:
        print("Yes")
    else:
        if N % 3 != 0:
            print("No")
        else:
            if cnt.most_common(1)[0][1] == N*2//3 and cnt[0] == N//3:
                print("Yes")
            else:
                x = cnt.most_common(3)
                if x[0][1] == x[1][1] == x[2][1]:
                    if x[0][0]^x[1][0]^x[2][0] == 0:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
except:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n-1):
  b.append(a[i-1]^a[i+1])
b.append(a[-2]^a[0])
a.sort()
b.sort()
if a==b:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
a = [a[-1]]+a+[a[0]]

for i in range(1, len(a)-1):
    if a[i-1]^a[i+1] != a[i]:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
a_counter_li = list(a_counter)
if sum(a) == 0:
    print("Yes")
elif len(a)%3 != 0:
    print("No")
elif len(a_counter) > 3 or len(a_counter) <= 1:
    print("No")
elif len(a_counter) == 3:
    if a_counter[a_counter_li[0]] == n // 3 and a_counter[a_counter_li[1]] == n // 3 and a_counter[a_counter_li[2]] == n // 3:
        if a_counter_li[0]^a_counter_li[1]^a_counter_li[2] == 0:
            print("Yes")
        else:
            print('No')
    else:
        print("No")
else:
    a_counter_li.sort()
    if a_counter_li[0] == 0 and a_counter[a_counter_li[0]] == n // 3:
        print("Yes")
    else:
        print("no")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
max_a = max(a)
if max_a == 0:
    print('Yes')
    exit()

if a.count(max_a) == 2*N//3 and a.count(0) == N//3:
    print('Yes')
    exit()

set_a = list(set(a))
if len(set_a) == 3:
    if a.count(set_a[0]) == a.count(set_a[1]) == a.count(set_a[2]):
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(sa)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
if len(sa) != 3:
    print("No")
    exit()

if B[sa[0]] == B[sa[1]] == B[sa[2]]:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")
else:
    print("No")

Submission status: Wrong Answer

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

if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(sa)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
    
if len(sa) != 3:
    print("No")
else:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a).most_common()

if len(c) == 3 and c[0][1] == c[1][1] == c[2][1]:
    x = c[0][0]
    y = c[1][0]
    z = c[2][0]
    if x^y == z and y^z == x and z^x == y:
        ans = "Yes"
    else:
        ans = "No"
if len(c) == 2 and c[0][1] == 2*c[1][1]:
    x = c[0][0]
    y = c[1][0]
    if x^x == y and x^y == x:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1 and c[0][0] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
num=a[0]
for i in range(1,n):
    num=num^a[i]
if max(a)==2**(n-3)+2**(n-4):
    print("Yes")
elif max(a)==min(a) and a[0]!=0:
    print("No")
elif num<=1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
num=a[0]
for i in range(1,n):
    num=num^a[i]
if max(a)==min(a) and a[0]!=0:
    print("No")
elif max(a)==2**(n-3)+2**(n-4):
    print("Yes")
elif num<=1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a).most_common()

if len(c) == 3 and c[0][1] == c[1][1] == c[2][1]:
    x = c[0][0]
    y = c[1][0]
    z = c[2][0]
    if x^y == z and y^z == x and z^x == y:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1:
    x = c[0][0]
    if x^x == x:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a)

if len(c) == 3 and c.most_common()[0][1] == c.most_common()[1][1] == c.most_common()[2][1]:
    x = c.most_common()[0][0]
    y = c.most_common()[1][0]
    z = c.most_common()[2][0]
    if x^y == z and y^z == x and z^x == y:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1 and c.most_common()[0][0] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a)

if len(c) == 3 and c.most_common()[0][1] == c.most_common()[1][1] == c.most_common()[2][1]:
    x = c.most_common()[0][0]
    y = c.most_common()[1][0]
    z = c.most_common()[2][0]
    if x^y == z and y^z == x and z^x == y:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
xor = [0]*9
for x in a:
    for i in range(9):
        xor[i] ^= x // (2**i)
chk = True
for i in range(9):
    if xor[i] != xor[i]^xor[i]:
        chk = False
print("Yes" if chk else "No")

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
xor = 0
for x in a:
    xor ^= x
if xor == xor^xor:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
A=[int(b) for b in a]
 
number=A[0]
 
for n in range(1,N):
    number=number^A[n]
 
if number==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
a = 0
for i in range(N):
    a ^= As[i]
if a==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

xor = A[0]
for i in range(1, N):
    xor ^= A[i]

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

Submission status: Wrong Answer

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

xor = 0
for i in range(N):
    xor ^= A[i]

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

Submission status: Wrong Answer

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

c=Counter(a)
bl=True
if n%3==0:
    if len(c.keys())==3:
        l=[]
        for i,j in c.items():
            if j!=n//3:
                bl=False
            l.append(i)
        if l[0]^l[1]!=l[2]:
            bl=False
    else:
        bl=False
else:
    bl=False
if c[0]==n:
    bl=True

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

Submission status: Wrong Answer

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

c=Counter(a)
bl=True
if n%3==0:
    if len(c.keys())==3:
        l=[]
        for i,j in c.items():
            if j!=n//3:
                bl=False
            l.append(i)
        l.sort()
        if l[0]+l[1]!=l[2]:
            bl=False
    else:
        bl=False
else:
    bl=False
if c[0]==n:
    bl=True

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

Submission status: Wrong Answer

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

c=Counter(a)
bl=True
if n%3==0:
    if len(c.keys())==3:
        l=[]
        for i,j in c.items():
            if j!=n//3:
                bl=False
            l.append(i)
        if abs(l[0]-l[1])!=l[2]:
            bl=False
    else:
        bl=False
else:
    bl=False
if c[0]==n:
    bl=True

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

Submission status: Wrong Answer

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

c=Counter(a)
bl=True
if n%3==0:
    if len(c.keys())==3:
        for i,j in c.items():
            if j!=n//3:
                bl=False
    else:
        bl=False
else:
    bl=False
if c[0]==n:
    bl=True

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

Submission status: Wrong Answer

Solution code:
N,*A = map(int, open(0).read().split())

B = []
for i in range(N):
    if i == 0:
        B.append(A[-1] ^ A[i+1])
    elif i == N-1:
        B.append(A[i-1] ^ A[0])
    else:
        B.append(A[i-1] ^ A[i+1])

print('Yes' if A == B else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter

n = int(input())
*a, = map(int, input().split())
c = Counter(a)
b = 0
for i in c.keys():
    b ^= i
if sum(a) == 0 or (b == 0 and all(i * 3 == n for i in c.values())):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
input()
ans = 0
for i in map(int, input().split()):
    ans ^= i
print("YNeos"[ans > 0::2])

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()
# 条件を満たす状態における 連続する 4 つの値に関して考えると
# a_i = a_(i+3) を満たす事がわかる
# 満たす条件は
# a1 ^ a2 ^ a3 = 0
# a_i = a_(i+3) -> 値が 3 種類以内
c = Counter(a)
n_uniq = len(c)
# 値が 3 種類以上であれば No
if n_uniq > 3:
    print('No')
#  a1, a2, a3 の場合分けを考える
# 3 種類の異なる値の場合 : a1, a2, a3 が n 枚のうちちょうど同じ数ずつある必要がある (-> n / 3 が 3 の倍数)
elif n_uniq == 3:
    a_1, a_2, a_3 = c.keys()
    if c[a_1] == c[a_2] == c[a_3]:
        print('Yes')
    else:
        print('No')
# 2 種類の異なる値の場合 : ある 1 つの値が必ず 0 -> 0 が n / 3 枚、 等しい数となる a_x は 2n / 3 枚
elif n_uniq == 2:
    a_1, a_2 = sorted(set(a))
    if a_1 == 0 and 3 * c[a_1] == n:
        print('Yes')
    else:
        print('No')
# 全て同じ値の場合 : 全て 0
else:
    if sum(a) == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()
# 条件を満たす状態における 連続する 4 つの値に関して考えると
# a_i = a_(i+3) を満たす事がわかる
# 満たす条件は
# a1 ^ a2 ^ a3 = 0
# a_i = a_(i+3) -> 値が 3 種類以内
c = Counter(a)
n_uniq = len(c)
# 値が 3 種類以上であれば No
if n_uniq > 3:
    print('No')
#  a1, a2, a3 の場合分けを考える
# 3 種類の異なる値の場合 : a1, a2, a3 が n 枚のうちちょうど同じ数ずつある必要がある (-> n // 3 が 3 の倍数)
elif n_uniq == 3:
    a_1, a_2, a_3 = c.keys()
    if c[a_1] == c[a_2] == c[a_3]:
        print('Yes')
    else:
        print('No')
# 2 種類の異なる値の場合 : ある 1 つの値が必ず 0 -> 0 が n // 3 枚、 等しい数となる a_x は 2n // 3 枚
elif n_uniq == 2:
    a_1, a_2 = sorted(set(a))
    if a_1 == 0 and 2 * c[a_1] == c[a_2]:
        print('Yes')
    else:
        print('No')
# 全て同じ値の場合 : 全て 0
else:
    if sum(a) == 0:
        print('Yes')
    else:
        print('No')