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 sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    for e in a:
        d[e] += 1
    ks = list(d.keys())
    m = len(ks)
    if m < 4:
        x = n / 3
        if m == 1 and ks[0] == 0:
            print("Yes")
        elif m == 2:
            if d[0] == x:
                print("Yes")
        elif m == 3:
            a, b, c = ks
            if d[a] == x and d[b] == x and (a^b^c) == 0:
                print("Yes")

    print("No")


    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    for e in a:
        d[e] += 1
    ks = list(d.keys())
    m = len(ks)
    if m < 4:
        x = n / 3
        if m == 1 and ks[0] == 0:
            print("Yes")
        elif m == 2:
            if d[0] == x:
                print("Yes")
        elif m == 3:
            a, b, c = ks
            if d[a] == x and d[b] == x:
                print("Yes")

    print("No")


    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    for e in a:
        d[e] += 1
    ks = list(d.keys())
    m = len(ks)
    if m < 4:
        x = n / 3
        if m == 1:
            print("Yes")
        elif m == 2:
            a, b = ks
            if d[a] == x or d[b] == x:
                print("Yes")
        elif m == 3:
            a, b, c = ks
            if d[a] == x and d[b] == x:
                print("Yes")

    print("No")


    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    x = 0
    for e in a:
        x ^= e
    if x == 0 and n != 4 or len(set(a)) == 1:
        print("Yes")
    else:
        print("No")

    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    x = 0
    for e in a:
        x ^= e
    if x or n == 4:
        print("No")
    else:
        print("Yes")

    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    x = 0
    for e in a:
        x ^= e
    if x:
        print("No")
    else:
        print("Yes")

    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = 0
for i in a:
    cnt ^= i

if cnt == n % 3 == 0 and all(a[i] % (n // 3) == 0 for i in a):
    print('Yes')
elif cnt == 0 and a[0] == n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = 0
for i in a:
    cnt ^= i

if n % 3 == 0 and cnt == 0:
    if all(a[i] % (n // 3) == 0 for i in a):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = a[0]
for i in range(1,N):
    ans ^= a[i]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int, input().split()))
s=set(a) # 検索用
from collections import Counter
d=Counter(a) # 重複用
for i in range(1, N):
  tmp=a[0]^a[i]
  if tmp not in s:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int, input().split()))
base=a[0]
s=set(a) # 検索用
from collections import Counter
d=Counter(a) # 重複用
for i in range(1, N):
  tmp=a[0]^a[i]
  if tmp in s:
    if d[tmp]>0:
      d[tmp]-=1
    else:
      print("No")
      exit()
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc035/tasks/agc035_a

n = int(input())
nums = [int(i) for i in input().split()]
num = 0
for i in range(n):
    num ^= nums[i]
if num == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc035/tasks/agc035_a

n = int(input())
nums = [int(i) for i in input().split()]
nums.sort()
for i in range(n):
    r = i - 1
    l = i + 1
    if l >= n:
        l = 0
    if nums[i] == nums[r] ^ nums[l]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc035/tasks/agc035_a

n = int(input())
nums = [int(i) for i in input().split()]

for i in range(n):
    r = i - 1
    l = i + 1
    if l >= n:
        l = 0
    if nums[i] == nums[r] ^ nums[l]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys,collections
input = sys.stdin.readline

N = int(input())
a =list(map(int,input().split()))
if N%3 != 0:
    print('No')
    exit()    

ac = collections.Counter(a)

if len(ac) != 3 :
    print('No')
    exit()
else:
    lk1,lk2,lk3 = ac.keys()
    lv1,lv2,lv3 = ac.values()
if lv1 == lv2 ==lv3:
    if lk1^lk2 == lk3:
        print('Yes')
    else:
        print('No')
else:
    print('No')
    exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
Left=list(map(int,input().split()))
Right=Left[2:]
Right.append(Left[0])
Right.append(Left[1])
Center=Left[1:]
Center.append(Left[0])

ans='No'


for i in range(N):
  if Left[i]^Right[i]==Center[i]:
    continue
  else:
    break
else:
  ans='Yes'
  
print(ans)

Submission status: Wrong Answer

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

if len(el) == 1:
  if el[0] == 0:
    print("Yes")
  else:
    print("No")
elif len(el) == 2 :
  if a.count(0)*2 == a.count(el[1]):
    print("Yes")
  else:
    print("No")
elif len(el) == 3 and el[0]^el[1]^el[2] == 0:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

if len(el) == 1:
  if el[0] == 0:
    print("Yes")
  else:
    print("No")
elif len(el) == 2 :
  if a.count(0)*2 == a.count(el[1]):
    print("Yes")
  else:
    print("No")
elif len(el) == 3:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = [int(e) for e in input().split()]

a_dict = dict()
for a in a_list:
    if a not in a_dict:
        a_dict[a] = 0
    a_dict[a] += 1

ans_list = list()

#最初の3つを求める
center = a_list[0]
a_dict[center] -= 1
if a_dict[center]==0:
    del a_dict[center]

for a in a_dict:
    if center^a in a_dict:
        if center^a == a:
            if a_dict[a]>=2:
                a_dict[a] -= 2
                if a_dict[a]==0:
                    del a_dict[a]
                first_NG_flag = False
                break
        else:
            a_dict[center^a] -= 1
            if a_dict[center^a]==0:
                del a_dict[center^a]
                
            a_dict[a] -= 1
            if a_dict[a]==0:
                del a_dict[a]

            first_NG_flag = False
            break
else:
    print("No")
    first_NG_flag = True
               
left = center^a
right = a
ans_list.append(left)
ans_list.append(center)
ans_list.append(right)

#以後を求める
if first_NG_flag == False:
    left = ans_list[-2]
    center = ans_list[-1]

    while 1:
        if len(a_dict)==0:
            right = ans_list[0]
            if left^right == center:
                print("Yes")
            else:
                print("No")
            break

        elif left^center in a_dict:
            a_dict[left^center] -= 1
            if a_dict[left^center] == 0:
                del a_dict[left^center]
            ans_list.append(left^center)

            left = ans_list[-2]
            center = ans_list[-1]
        else:
            print("No")
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = [int(e) for e in input().split()]

a_dict = dict()
for a in a_list:
    if a not in a_dict:
        a_dict[a] = 0
    a_dict[a] += 1

ans_list = list()

#最初の3つを求める
center = a_list[0]
a_dict[center] -= 1
if a_dict[center]==0:
    del a_dict[center]

for a in a_dict:
    if center^a in a_dict:
        if center^a == a:
            if a_dict[a]>=2:
                a_dict[a] -= 2
                if a_dict[a]==0:
                    del a_dict[a]
                first_NG_flag = False
                break
        else:
            a_dict[center^a] -= 1
            if a_dict[center^a]==0:
                del a_dict[center^a]
            first_NG_flag = False
            break
else:
    print("No")
    first_NG_flag = True
               
left = center^a
right = a
ans_list.append(left)
ans_list.append(center)
ans_list.append(right)

#以後を求める
if first_NG_flag == False:
    left = ans_list[-2]
    center = ans_list[-1]

    while 1:
        if len(a_dict)==0:
            right = ans_list[0]
            if left^right == center:
                print("Yes")
            else:
                print("No")
            break

        elif left^center in a_dict:
            a_dict[left^center] -= 1
            if a_dict[left^center] == 0:
                del a_dict[left^center]
            ans_list.append(left^center)

            left = ans_list[-2]
            center = ans_list[-1]
        else:
            print("No")
            break

Submission status: Wrong Answer

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

if N%3 == 0:
    if len(set(A)) <= 3:
        print('Yes')
    else:
        print('No')

elif N%3 != 0:
    if len(set(A)) == 2 and 0 in A:
        print('Yes')
    elif len(set(A)) == 1 and 0 in A:
        print('No')
    else:
        print('No')

Submission status: Wrong Answer

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

if N%3 == 0:
    if len(set(A)) <= 3:
        print('Yes')
    else:
        print('No')

elif N%3 != 0:
    if len(set(A)) <= 2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if len(set(A)) <= 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
a = l()

for i in range(1,N-1):
    if a[i-1]^a[i+1] == a[i]:
        pass
    else:
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

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

d={}
for h in range(1,N):
    if a[h] in d:
        d[a[h]]+=1
    else:
        d[a[h]]=1
ans="Yes"
b=[a[0],a[1]]
for i in range(1,N):
    if i==N-1:
        t=b[N-1]^b[N-2]
        if t!=b[0]:
            ans="No"
        break
    t=b[i-1]^b[i]
    if t in d:
        b.append(t)
        d[t]-=1
        if d[t]==0:
            del d[t]
    else:
        ans="No"
        break

print(ans)

Submission status: Wrong Answer

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

d={}
for A in a:
    if A in d:
        d[A]+=1
    else:
        d[A]=1
ans="Yes"
b=[a[0],a[1]]
for i in range(1,N):
    if i==N-1:
        t=b[N-1]^b[N-2]
        if t!=b[0]:
            ans="No"
        break
    t=b[i-1]^b[i]
    if t in d:
        b.append(t)
        d[t]-=1
        if d[t]==0:
            del d[t]
    else:
        ans="No"
        break

print(ans)

Submission status: Wrong Answer

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

d={}
for A in a:
    if A in d:
        d[A]+=1
    else:
        d[A]=1
ans="Yes"
b=[a[0],a[1]]
for i in range(1,N):
    if i==N-1:
        t=b[-1]^b[-2]
        if t!=b[0]:
            ans="No"
        break
    t=b[i-1]^b[i]
    if t in d:
        b.append(t)
        d[t]-=1
        if d[t]==0:
            del d[t]
    else:
        ans="No"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
flg=False
if all(a[i]==0 for i in range(n)):flg=True
if n%3==0:
    l=Counter(a)
    ans=l.most_common()
    if len(ans)==2:
        flg1,flg2=False,False
        for i,j in ans:
            if i==0 and n//j==2:
                flg1=True
            if j/n==2/3:
                flg2=True
            if flg1 and flg2:
                flg=True
    if len(ans)==3:
        flg3=True
        tmp=0
        for i in range(3):
            tmp^ans[i][0]
            if ans[i][1]*3!=n:
                flg3=False
            if flg3 and tmp==0:
                flg=True
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
if len(d) != 3:
    print('No')
else:
    x = list(d.items())
    if d[x[0]] == d[x[1]] and d[x[1]] == d[x[2]]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
if len(C) == 2:
    if C[0] == 0:
        print('No')
        exit()
    x = 0
    y = 0
    for i,v in C.items():
        if i == 0 :
            x = v
        else:
            y = v
    if 2 * x == y:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
if len(C) == 2:
    if C[0] == 0:
        print('No')
        exit()
    x = 0
    y = 0
    for i,v in C.items():
        if i == 0 :
            x = v
        else:
            y = v
    if 2 * x == y:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()

Submission status: Wrong Answer

Solution code:
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
if len(C) == 2:
    if C[0] == 0:
        print('No')
        exit()
    x,y = C.values()
    if x == 3 * y or y == 3 * x:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()

Submission status: Wrong Answer

Solution code:
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
if len(C) == 2:
    if C[0] == 0:
        print('No')
        exit()
    # x,y = C.values()
    # if x//3==y or y//3==x:
    #     print('Yes')
    #     exit()
    # else:
    #     print('No')
    #     exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()

Submission status: Wrong Answer

Solution code:
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
# if len(C) == 2:
#     if C[0] == 0:
#         print('No')
#         exit()
#     x,y = C.values()
#     if x//3==y or y//3==x:
#         print('Yes')
#         exit()
#     else:
#         print('No')
#         exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()

Submission status: Wrong Answer

Solution code:
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
# if len(C) == 2:
#     if C[0] == 0:
#         print('No')
#         exit()
#     x,y = C.values()
#     if x//3==y or y//3==x:
#         print('Yes')
#         exit()
#     else:
#         print('No')
#         exit()
# if len(C) == 1:
#     if C[0]>0:
#         print('Yes')
#         exit()

Submission status: Wrong Answer

Solution code:

import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
if len(C) == 2:
    if C[0] == 0:
        print('No')
        exit()
    x,y = C.values()
    if x//3==y or y//3==x:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    b = a[0]
    for i in range(n-1):
        b = b^a[i]
    for i in range(n):
        if a[i]^a[i-2] != a[i-1]:
            print("No")
            sys.exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

a = LIST()
C = Counter(a)
A = sorted(set(a))

if N%3 == 0:
	if len(A) == 3 and A[0]^A[1] == A[2] and len(set(C.values())):
		print("Yes")
	elif len(A) == 2 and A[0] == 0 and C[0] == N//3:
		print("Yes")
	elif len(A) == 1 and A[0] == 0:
		print("Yes")
	else:
		print("No")

elif len(A) == 1 and 0 in a:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

a = LIST()
C = Counter(a)
A = sorted(set(a))

if N%3 == 0:
	if len(A) == 3 and A[0]^A[1] == A[2] and len(set(C.values())):
		print("Yes")
	elif len(A) == 2 and A[0] == 0 and C[0] == N//3:
		print("Yes")
	else:
		print("No")

elif len(A) == 1 and 0 in a:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

a = LIST()
C = Counter(a)
A = list(set(a))

if N%3 == 0 and len(A) == 3 and A[0]^A[1] == A[2] and len(set(C.values())) == 1:
	print("Yes")
elif len(A) == 1 and 0 in a:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

a = LIST()
C = Counter(a)
A = list(set(a))

if N%3 == 0 and len(a) == 3 and A[0]^A[1] == A[2] and len(set(C.values())) == 1:
	print("Yes")
elif len(A) == 1 and 0 in a:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

a = LIST()
C = Counter(a)
A = list(set(a))

if N%3 == 0 and len(a) == 3 and A[0]^A[1] == A[2] and len(set(C.values())) == 1:
	print("Yes")
elif len(a) == 1 and 0 in a:
	print("Yes")
else:
	print("No")