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
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

if sum(a) == 0:
    print('Yes')
    exit()

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

from collections import Counter

ac = Counter(a).most_common()

if len(ac) == 3 and ac[0][1] == ac[1][1] == ac[2][1]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

if sum(a) == 0:
    print('Yes')
    exit()

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7
 
N = int(readline())
a = list(map(int,readline().split()))

a.sort()
 
if a[0] != a[1] ^ a[-1] or a[-1] != a[-2] ^ a[0]:
    print('No')
    exit()
 
ans = 'Yes'
 
for i in range(N-2):
    if a[i] ^ a[i+2] != a[i+1]:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

if a[0] != a[1] ^ a[-1] or a[-1] != a[-2] ^ a[0]:
    print('No')
    exit()

ans = 'Yes'

for i in range(N-2):
    if a[i] ^ a[i+2] != a[i+1]:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
L = list(map(int,input().split()))
L = deque(L)
L.append(L[0])
L.appendleft(L[n-1])
#print(L)
flag = False
for i in range(n):
    if L[i]^L[i+2] == L[i+1]:
        flag = True
    else:
        print("No")
        exit()
if flag:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

c = {}
for e in a:
    c.setdefault(e, 0)
    c[e] += 1

t = {}
for x, y in combinations(set(a), 2):
    i = x
    j = y
    t[i] = 1
    t.setdefault(j, 0)
    t[j] += 1
    for _ in range(N - 2):
        k = i ^ j
        t.setdefault(k, 0)
        t[k] += 1
        c.setdefault(k, 0)
        if t[k] > c[k]:
            j = -1
            break
        i, j = j, k
    if j ^ x == y:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
# 284578934573回アタックしてたやつ
# 手を動かすと（最初の2つを固定して3つ目を同定、2つ目と3つ目から4つ目を同定...として5個くらい書いた)
# - 全部異なる数字が1/3個ずつある これは奇数が2種類で偶数が1種類
# - 1/3が0であとは単一の数字
# になった（あってんのかこれ
# あーあと 全部0の場合もべつにいいか
# ここまでやったのに3WAが取れない

n = int(input())
arr = list(map(int, input().split()))
d = {}
for a in arr:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
if 0 not in d and n % 3 != 0:
    print("No")
elif 0 in d:
    if len(d) == 1 or (len(d) == 2 and d[0] == n // 3):
        print("Yes")
    else:
        print("No")
elif len(d) == 3 and len(set(d.values())) == 1:
    o, e = 0, 0
    for k, _ in d.items():
        if k % 2 == 0:
            e += 1
        else:
            o += 1
    if e == 1 and o == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# 284578934573回アタックしてたやつ
# 手を動かすと（最初の2つを固定して3つ目を同定、2つ目と3つ目から4つ目を同定...として5個くらい書いた)
# - 全部異なる数字が1/3個ずつある これは奇数が2種類で偶数が1種類
# - 1/3が0であとは単一の数字
# になった（あってんのかこれ
# あーあと 全部0の場合もべつにいいか
n = int(input())
arr = list(map(int, input().split()))
d = {}
for a in arr:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
if 0 not in d and n % 3 != 0:
    print("No")
elif 0 in d:
    if len(d) == 1 or (len(d) == 2 and d[0] == n // 3):
        print("Yes")
elif len(d) == 3 and len(set(d.values())) == 1:
    o, e = 0, 0
    for k, _ in d.items():
        if k % 2 == 0:
            e += 1
        else:
            o += 1
    if e == 1 and o == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# 284578934573回アタックしてたやつ
# 手を動かすと（最初の2つを固定して3つ目を同定、2つ目と3つ目から4つ目を同定...として5個くらい書いた)
# - 全部異なる数字が1/3個ずつある これは奇数が1種類で偶数が2種類
# - 1/3が0であとは単一の数字
# になった（あってんのかこれ
# あーあと 全部0の場合もべつにいいか
n = int(input())
arr = list(map(int, input().split()))
d = {}
for a in arr:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
if 0 not in d and n % 3 != 0:
    print("No")
elif 0 in d:
    if len(d) == 1 or (len(d) == 2 and d[0] == n // 3):
        print("Yes")
elif len(d) == 3 and len(set(d.values())) == 1:
    o, e = 0, 0
    for k, _ in d.items():
        if k % 2 == 0:
            e += 1
        else:
            o += 1
    if e == 2 and o == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# 284578934573回アタックしてたやつ
# 手を動かすと（最初の2つを固定して3つ目を同定、2つ目と3つ目から4つ目を同定...として5個くらい書いた)
# - 全部異なる数字が1/3個ずつある
# - 1/3が0であとは単一の数字
# になった（あってんのかこれ
# あーあと 全部0の場合もべつにいいか
n = int(input())
arr = list(map(int, input().split()))
d = {}
for a in arr:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
if 0 not in d and n % 3 != 0:
    print("No")
elif 0 in d:
    if len(d) == 1 or (len(d) == 2 and d[0] == n // 3):
        print("Yes")
elif len(d) == 3 and len(set(d.values())) == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# 284578934573回アタックしてたやつ
# 手を動かすと（最初の2つを固定して3つ目を同定、2つ目と3つ目から4つ目を同定...として5個くらい書いた)
# - 全部異なる数字が1/3個ずつある
# - 1/3が0であとは単一の数字
# になった（あってんのかこれ
# あーあと 全部0の場合もべつにいいか
n = int(input())
if n % 3 != 0:
    print("No")
    exit()
arr = list(map(int, input().split()))
d = {}
for a in arr:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
if 0 in d:
    if len(d) == 1 or (len(d) == 2 and d[0] == n // 3):
        print("Yes")
elif len(d) == 3 and len(set(d.values())) == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

if n % 3 or len(set(a)) == 1:
    print('Yes' if len(set(a)) == 1 else 'No')
else:
    d = Counter()
    for x in a:
        d[x] += 1
    if len(d.keys()) == 2:
        print('Yes' if a.count(a[0]) in [n//3, 2 * n//3] else 'No')
        exit()
    for x in d.keys():
        if d[x] != n//3:
            print('No')
            exit()
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = nl()

sa = set(a)
l = len(sa)

if l == 1:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(a) % 3 == 0:
    if l == 2:
        if a.count(0) == n // 3:
            print('Yes')
        else:
            print('No')
    elif l == 3:
        if all([a.count(ele) == n // 3 for ele in sa]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = nl()

sa = set(a)
l = len(sa)

if l == 0:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(a) % 3 == 0:
    if l == 2:
        if a.count(0) == n // 3:
            print('Yes')
        else:
            print('No')
    elif l == 3:
        if all([a.count(ele) == n // 3 for ele in sa]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = nl()

sa = set(a)
l = len(sa)

if l == 0:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif l % 3 == 0:
    if l == 2:
        if a.count(0) == n // 3:
            print('Yes')
        else:
            print('No')
    elif l == 3:
        if all([a.count(ele) == n // 3 for ele in sa]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
_, *a = map(int, open(0).read().split());z = 0
for b in a:z ^= b
print("YNeos"[z>0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
if n % 3 == 0 and len(A) == 3 and bin(A[0]^A[1]) == bin(A[2]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
from functools import reduce
from operator import xor
n = int(input())
a = Counter(map(int , input().split()))

if n % 3 == 0:
    if len(a) == 3:
        if 0 == reduce(xor, a) and all(v == n // 3 for v in a.values()):
            print("Yes")
        else:
            print("No")
    elif len(a) == 2:
        if 0 in a and a[0] == n // 3:
            print("Yes")
        else:
            print("No")
    else:
        if 0 in a:
            print("Yes")
        else:
            print("No")
else:
    if 0 in a:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = float(input())
data = list(map(int, input().split()))
t = count(data)
if len(t) == 3:
    if 0 not in t and all(i == n/3 for i in t.values()):
        print('Yes')
    else:
        print('No')

elif len(t) == 2:
    if 0 in t and t[0] == n/3:
        print('Yes')
    else:
        print('No')

elif len(t) == 1:
    if 0 in t:
        print('Yes')
    else:
        print('No')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = float(input())
data = list(map(int, input().split()))
t = count(data)
if len(t) == 3:
    if 0 not in t and all(i == n/3 for i in t.values()):
        print('YES')
    else:
        print('NO')

elif len(t) == 2:
    if 0 in t and t[0] == n/3:
        print('YES')
    else:
        print('NO')

elif len(t) == 1:
    if 0 in t:
        print('YES')
    else:
        print('NO')

else:
    print('NO')

Submission status: Wrong Answer

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

# 排他的論理和は3つずつ循環するため、満たすべき条件は以下
# nが3の倍数である, 数字が3種類で同数, 3種類が排他的論理和の関係になっている

if n % 3 != 0:
    print("No")
    sys.exit()

c = Counter(a)

if len(c.keys()) != 3:
    print("No")
    sys.exit()

cli = list(c.keys())
cval = list(c.values())

if not all([x == cval[0] for x in cval]):
    print("No")
    sys.exit()

ans_0 = cli[1] ^ cli[2] == cli[0]
ans_1 = cli[2] ^ cli[0] == cli[1]
ans_2 = cli[0] ^ cli[1] == cli[2]

print("Yes" if all([ans_0, ans_1, ans_2]) else "No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
from collections import deque,defaultdict,Counter

def main():
    N = int(input())
    A = list(map(int,input().split()))
    if N%3 == 0:
        C = Counter(A)
        if len(C) == 3 and all(v*3 == N for v in C.values()):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

if len(set(a)) == 1 and list(set(a))[0] == 0:
    print('Yes')
    exit()

if n % 3 == 0 and len(set(a)) == 3:
    x = list(set(a))
    e = x[0]
    b = x[1]
    c = x[2]
    if e ^ b != c:
        print('No')
        exit()
    if b ^ c != e:
        print('No')
        exit()
    if c ^ e != b:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[e] != d[b] or d[b] != d[c] or d[c] != d[e]:
        print('No')
        exit()
    print('Yes')
elif n % 2 == 0 and len(set(a)) == 2:
    x = list(set(a))
    x.sort()
    if x[0] == 0:
        t = 1
    else:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[x[0]]*2 == d[x[1]]:
        print('Yes')
        exit()
    print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

if n % 3 == 0 and len(set(a)) == 3:
    x = list(set(a))
    e = x[0]
    b = x[1]
    c = x[2]
    if e ^ b != c:
        print('No')
        exit()
    if b ^ c != e:
        print('No')
        exit()
    if c ^ e != b:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[e] != d[b] or d[b] != d[c] or d[c] != d[e]:
        print('No')
        exit()
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

if n % 3 == 0 and len(set(a)) == 3:
    x = list(set(a))
    e = x[0]
    b = x[1]
    c = x[2]
    if e ^ b != c:
        print('No')
        exit()
    if b ^ c != e:
        print('No')
        exit()
    if c ^ e != b:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[e] != d[b] or d[b] != d[c] or d[c] != d[e]:
        print('No')
        exit()
    print('Yes')
elif n % 2 == 0 and len(set(a)) == 2:
    x = list(set(a))
    x.sort()
    if x[0] == 0:
        t = 1
    else:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[x[0]] != d[x[1]]:
        print('No')
        exit()
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if n % 3 == 0 and len(set(a)) == 3:
    x = list(set(a))
    a = x[0]
    b = x[1]
    c = x[2]
    if a ^ b != c:
        print('No')
        exit()
    if b ^ c != a:
        print('No')
        exit()
    if c ^ a != b:
        print('No')
        exit()
    print('Yes')
elif n % 2 == 0 and len(set(a)) == 2:
    x = list(set(a))
    x.sort()
    if x[0] == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

if n % 3 == 0 and len(set(a)) == 3:
    x = list(set(a))
    a = x[0]
    b = x[1]
    c = x[2]
    if a ^ b != c:
        print('No')
        exit()
    if b ^ c != a:
        print('No')
        exit()
    if c ^ a != b:
        print('No')
        exit()
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
import copy

N=int(input())
a=list(map(int,input().split()))
A={}
for h in range(N):
    if a[h] in A:
        A[a[h]]+=1
    else:
        A[a[h]]=1
A[a[0]]-=1
ans="No"
for i in range(1,N):
    temp=copy.copy(A)
    P=[a[0],a[i]]
    temp[a[i]]-=1
    for j in range(2,N):
        x=P[j-1]^P[j-2]
        if x in A and A[x]>0:
            P.append(x)
            temp[x]-=1
        else:
            break
    if len(P)==N:
        if P[-2]^P[-1]==P[0] and P[-1]^P[0]==P[1]:
            ans="Yes"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
A={}
for h in range(N):
    if a[h] in A:
        A[a[h]]+=1
    else:
        A[a[h]]=1

ans="No"
for i in range(1,N):
    temp=A.copy
    P=[a[0],a[i]]
    for j in range(2,N):
        x=P[j-1]^P[j-2]
        if x in A and A[x]>0:
            P.append(x)
            A[x]-=1
        else:
            break
    if len(P)==N:
        if P[-2]^P[-1]==P[0] and P[-1]^P[0]==P[1]:
            ans="Yes"
            break

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
A={}
for h in range(N):
    if a[h] in A:
        A[a[h]]+=1
    else:
        A[a[h]]=1

ans="No"
for i in range(1,N):
    temp=A.copy
    P=[a[0],a[i]]
    for j in range(2,N):
        x=P[-1]^P[-2]
        if x in A and A[x]>0:
            P.append(x)
            A[x]-=1
        else:
            break
    if len(P)==N and P[-1]^P[-2]==P[0] and P[-1]^P[0]==P[1]:
        ans="Yes"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
A={}
for h in range(N):
    if a[h] in A:
        A[a[h]]+=1
    else:
        A[a[h]]=1

ans="No"
for i in range(1,N):
    temp=A.copy
    P=[a[0],a[i]]
    for j in range(2,N):
        x=P[-1]^P[-2]
        if x in A and A[x]>0:
            P.append(x)
            A[x]-=1
        else:
            break
    if len(P)==N and P[-1]^P[-2]==P[0]:
        ans="Yes"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
A={}
for h in range(N):
    if a[h] in A:
        A[a[h]]+=1
    else:
        A[a[h]]=1

ans="No"
for i in range(1,N):
    temp=A.copy
    P=[a[0],a[i]]
    for j in range(2,N):
        x=P[-1]^P[-2]
        if x in A and A[x]>0:
            P.append(x)
            A[x]-=1
        else:
            break
    if len(P)==N:
        ans="Yes"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = Counter(LI())
    ok = True
    for a,c in A.items():
        if(N%3==0):
            if(c%(N//3)!=0):
                ok = False
        else:
            if(c!=N):
                ok = False
    if(ok):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
if n%3 != 0:
  print('No')
else:
  a = [int(i) for i in input().split()]
  s = set(a)
  c = Counter(a)
  if len(c) > 3:
      print('No')
  elif len(c) == 3:
    a,b,q = list(s)
    if a^b == q and c[a] == n//3 and c[b] == c[q]:
      print('Yes')
    else:
      print('No')
  elif len(c) == 2:
    if not 0 in s:
      print('No')
    else:
      if c[0] == n//3:
        print('Yes')
      else:
        print('No')
  elif len(c) == 1:
    if s == {0}:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
if n%3 != 0:
  print('No')
else:
  a = [int(i) for i in input().split()]
  s = set(a)
  c = Counter(a)
  if len(c) > 3:
      print('No')
  elif len(c) == 3:
    a,b,c = list(s)
    if a^b == c:
      print('Yes')
    else:
      print('No')
  elif len(c) == 2:
    if not 0 in s:
      print('No')
    else:
      if c[0] == n//3:
        print('Yes')
      else:
        print('No')
  elif len(c) == 1:
    if s == {0}:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
if n%3 != 0:
  print('No')
else:
  a = [int(i) for i in input().split()]
  c = Counter(a)
  for i in c.values():
    if i != n//3:
      print('No')
      exit()
  print('Yes')

Submission status: Wrong Answer

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

if n%2==1:
    tmp=0
    for item in a:
        tmp=tmp^item
    if tmp==0:
        print("Yes")
    else:
        print("No")
else:
    tmp=0
    for item in a:
        tmp=tmp^item
    if tmp==2**len(str(bin(max(a))[2:]))-1:
        print("Yes")
    else:
        print("No")



#001 (1)
#010 (2)
#011 (3)
#001 (1)
#010 (2)
#011 (3)

#010 (2)
#011 (3)
#001 (1)

#011 (3)
#001 (1)
#010 (2)

Submission status: Wrong Answer

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


As = set(A)

if len(As) == 3:
    k = 0
    x, y, z = As
    if x^y != z and x^z != y and y^z != x:
        print('No')
        k = 1
    n = N // 3
    if k == 0:
        for i in [x, y, z]:
            if A.count(i) != n and A.count(i) != n+1:
                k = 1
                print('No')
                break
        if k == 0:
            print('Yes')
elif len(As) == 2:
    k = 0
    if 0 in As:
        if A.count(0) == 2:
            pass
        elif A.count(0) == N//3 or A.count(0) == N//3 + 1:
            k = 1
            print('Yes')
    if k == 0:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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


As = set(A)

if len(As) == 3:
    k = 0
    x, y, z = As
    if x^y != z and x^z != y:
        print('No')
        k = 1
    n = N // 3
    if k == 0:
        for i in [x, y, z]:
            if A.count(i) != n and A.count(i) != n+1:
                k = 1
                print('No')
                break
        if k == 0:
            print('Yes')
elif len(As) == 2:
    k = 0
    if 0 in As:
        if A.count(0) == 2:
            pass
        elif A.count(0) == N//3 or A.count(0) == N//3 + 1:
            k = 1
            print('Yes')
    if k == 0:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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


As = set(A)

if len(As) == 3:
    k = 0
    x, y, z = As
    if x^y != z and x^z != y:
        print('No')
        k = 1
    n = N // 3
    if k == 0:
        for i in [x, y, z]:
            if A.count(i) != n and A.count(i) != n-1:
                k = 1
                print('No')
                break
        if k == 0:
            print('Yes')
if len(As) == 2:
    k = 0
    if 0 in As:
        if A.count(0) == N//3 or A.count(0) == N//3 + 1:
            k = 1
            print('Yes')
    if k == 0:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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


As = set(A)

if len(As) == 3:
    k = 0
    x, y, z = As
    if x^y != z and x^z != y:
        print('No')
        k = 1
    n = N // 3
    if k == 0:
        for i in [x, y, z]:
            if A.count(i) != n and A.count(i) != n-1:
                k = 1
                print('No')
                break
        if k == 0:
            print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

k = 0
for i in range(-2, N-2):
    if not A[i+1] == (A[i] ^ A[i+2]):
        k = 0
        print('No')
        break
    k = 1

if k == 1:
    print('Yes')

Submission status: Wrong Answer

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

for i in range(N-2):
    if not A[i+1] == (A[i] ^ A[i+2]):
        k = 0
        print('No')
        break
    k = 1

if k == 1:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = a + a
for i in range(n):
    x1 = A[i - 1]
    x2 = A[i + 1]
    if bin(x1 ^ x2) != bin(a[i]):
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

for i in range(1,n+1):
    if A[i-1]^A[i+1]!=A[i]:
        print('No');exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    counter = Counter(A)

    if len(counter.keys()) == 1:
        print('Yes')
    elif len(counter.keys()) == 2:
        if set(counter.values()) == {N//3,(2*N)//3}:
            print('Yes')
        else:
            print('No')

    elif len(counter.keys()) == 3:
        for _,val in counter.items():
            if val != N // 3:
                print('No')
                return
        else:
            print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    counter = Counter(A)

    if len(counter.keys()) != 3:
        print('No')
        return

    for _,val in counter.items():
        if val != N // 3:
            print('No')
            return
    
    print('Yes')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
if len(c) == 3:
    l = list(c.keys())
    v = list(c.values())
    if l[0]^l[1]^l[2] == 0 and v[0]==v[1]==v[2]:
        print("Yes")
elif len(c) == 1:
    if list(c.keys())[0] == 0:
        print("Yes")
elif len(c) == 2:
    if (0 not in a):
        print("No")
    else:
        v = c[0]
        if len(a) == c[0]*3:
            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)
if len(c) == 3:
    l = list(c.keys())
    v = list(c.values())
    if l[0]^l[1]^l[2] == 0 and v[0]==v[1]==v[2]:
        print("Yes")
elif len(c) == 1:
    if list(c.keys())[0] == 0:
        print("Yes")
elif len(c) == 2:
    if (0 not in a):
        print("No")
    else:
        v = c[0]
        if len(a) == c[0]*3/2 or len(a) == c[0]*3:
            print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N = int(input())
A = list(map(int, input().split()))

if N >= 4:
    print('No')
    exit()

A = sorted(A)
if A[0] + A[1] == A[2]:
    print('Yes')

for a, b in permutations([1, 2, 3, 5], r=2):
    print('a, b, a ^ b', a, b, a ^ b)
# 条件が成立していたら足し算か引き算になる？ a + b = c, a - b = c

# 1 2 3 5

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N = int(input())
A = list(map(int, input().split()))

if N >= 4:
    print('No')
    exit()

A = sorted(A)
if A[0] + A[1] == A[2]:
    print('Yes')

    # for a, b in permutations([1, 4, 5], r=2):
    # print('a, b, a ^ b', a, b, a ^ b)
# 条件が成立していたら足し算か引き算になる？ a + b = c, a - b = c

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
x = list(map(int,input().split()))
c = Counter(x)
k = list(c.keys())
k.sort()
v = list(c.values())
if len(c)==3:
    if v[0]==v[1]==v[2]:
        if k[0]^k[2]==k[1]:
            print('Yes')
            exit()
elif len(c)==1:
    if k[0]^k[0]==k[0]:
        print('Yes')
        exit()
elif len(c)==2:
    if k[0]^k[0]==k[1] and k[1]^k[1]==k[0]:
        if v[0]==v[1]:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
x = list(map(int,input().split()))
c = Counter(x)
k = list(c.keys())
k.sort()
v = list(c.values())
if len(c)==3:
    if v[0]==v[1]==v[2]:
        if k[0]^k[2]==k[1]:
            print('Yes')
            exit()
elif len(c)==1:
    if k[0]^k[0]==k[0]:
        print('Yes')
        exit()
elif len(c)==2:
    if k[0]^k[1]==k[0] or k[0]^k[1]==k[1]:
        if v[0]==v[1]:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
x = list(map(int,input().split()))
c = Counter(x)
k = list(c.keys())
k.sort()
v = list(c.values())
if len(c)==3:
    if v[0]==v[1]==v[2]:
        if k[0]^k[2]==k[1]:
            print('Yes')
            exit()
print('No')