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 math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
a = iln()
if N % 3 != 0:
    for i in range(N):
        if a[i] != 0:
            print('No')
            break
    else:
        print('Yes')
else:
    v = [a[0],a[1],a[0]^a[1]]
    for i in range(N):
        if a[i] != v[i%3]:
            print('No')
            break
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
a = iln()
if N % 3 != 0:
    for i in range(N):
        if a[i] != 0:
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(N):
        if a[i-1] ^ a[(i+1)%N] ^ a[i] != 0:
            print('No')
            break
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
a = iln()

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

Submission status: Wrong Answer

Solution code:
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
a = iln()

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if n==3:
    if a[0]^a[1]==a[2]:
        print("Yes")
        exit()
if n%3==0:
    for j in range(3):
        for i in range(j*(n//3),(j+1)*(n//3)-1):
            if a[i]!=a[i+1]:
                print("No")
                exit()
    print("Yes")
    exit()
for i in range(0,n-1):
    if a[i]!=a[i+1]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if n==3:
    if a[0]^a[1]==a[2]:
        print("Yes")
        exit()
if n%3==0:
    for j in range(3):
        for i in range(j*(n//3),(j+1)*(n//3),3):
            if a[i]!=a[i+1]:
                print("No")
                exit()
    print("Yes")
    exit()
for i in range(0,n-1):
    if a[i]!=a[i+1]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if n==3:
    if a[0]^a[1]==a[2]:
        print("Yes")
        exit()
if n%3==0:
    for j in range(3):
        for i in range(j*(n//3),(j+1)*(n//3),3):
            if a[i]!=a[i+1]:
                print(a[i])
                print("No")
                exit()
    print("Yes")
    exit()
for i in range(0,n-1):
    if a[i]!=a[i+1]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = list(map(int,input().split()))
if (not 0) not in a:
    print('Yes')
else:
    if len(a)%3 != 0:
        print('No')
    else:
        counter = Counter(a)
        keys = list(counter.keys())
        vlen = len(set(counter.values()))
        if len(keys) >= 4:
            print('No')
        else:
            if len(keys) == 1:
                if keys[0] == 0:
                    print('Yes')
                else:
                    print('No')
            elif len(keys) == 2:
                if 0 in counter:
                    if counter[0] == N//3:
                        print('Yes')
                    else:
                        print('No')
                else:
                    print('No')
                
            else:
                if (vlen == 1) and (keys[0]^keys[1]^keys[2] == 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()))
if not (not 0) in a:
    print('Yes')
else:
    if len(a)%3 != 0:
        print('No')
    else:
        dicta = Counter(a)
        keys = list(dicta.keys())
        if len(keys) == 1:
            if 0 in dicta:
                print('Yes')
            else:
                print('No')
        elif len(keys) == 2:
            if dicta[0] == N//3:
                print('Yes')
            else:
                print('No')
        elif len(keys) == 3:
            flag = True
            for j in dicta.values():
                if j != N//3:
                    print('No')
                    flag = False
            if flag:
                if keys[0]^keys[1]^keys[2] == 0:
                    print('Yes')
                else:
                    print('No')
                
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = list(set(a))
if len(x) >= 4:
  print("No")
  exit()
if len(x) == 3:
  if x[0]^x[1] == x[2] and 3*a.count(x[0]) == 3*a.count(x[1]) == 3*a.count(x[2]) == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 2:
  if (x[0] == 0 or x[1] == 0) and 2*a.count(x[0]) == 2*a.count(x[1]) == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 1:
  if x[0] == 0:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = list(set(a))
if len(x) >= 4:
  print("No")
  exit()
if len(x) == 3:
  if x[0]^x[1] == x[2] and 3*a.count(x[0]) == 3*a.count(x[1]) == 3*a.count(x[2]) == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 2:
  if x[0] == 0 or x[1] == 0 and 2*a.count(x[0]) == 2*a.count(x[1]) == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 1:
  if x[0] == 0:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = "Yes"
if N % 3 != 0:
  print("No")
else:
  for i in range(N - 1):
    if not A[i] ^ A[i + 1] in A:
      ans = "No"
  print(ans)

Submission status: Wrong Answer

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

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

from collections import Counter

Count_a = Counter(a)

if Count_a[0] == N:
    print("Yes")
    exit()

if N % 3 != 0:
    print("No")
    exit()

if len(Count_a) == 2:
    if Count_a[0] == N // 3:
        print("Yes")
    else:
        print("No")
elif len(Count_a) == 3:
    three = [k for k,_ in Count_a.items()]
    if three[0] ^ three[1] == three[2]:
        for i in range(3):
            if Count_a[three[i]] != N // 3:
                print("No")
                exit()
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

counter = {}
nkey = 0
for i in range(n):
  if a[i] in counter.keys():
    counter[a[i]] += 1
  else:
    counter[a[i]] = 1
    nkey += 1
  if nkey >= 4:
    print('No')
    break
else:
  if nkey == 3:
    for key in counter.keys():
      if counter[key] != n // 3:
        print('No')
        break
    else:
      a = list(set(a))
      if a[0]^a[1]^a[2] == 0:
        print('Yes')
      else:
        print('No')
  else:
    print('No')

Submission status: Wrong Answer

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

if len(a) != 3:
  print('No')
else:
  if a[0]==a[1]^a[2]:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] += 1

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] >= 1:
        if a[0] == 0:
            if table[a[i]] == 1:
                continue
        ans[1] = (a[0] ^ a[i])
        ans[2] = a[i]
        table[ans[1]] -= 1
        table[ans[2]] -= 1
        break

if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] >= 1 and table[ans[i-1] ^ ans[i-2]] >= 1:
        if (table[ans[i-1]] == 0 or table[ans[i-2]] == 0) and table[ans[i-1] ^ ans[i-2]] == 1:
            print("No")
            exit(0)
        ans[i] = ans[i-1] ^ ans[i-2]
        table[ans[i]] -= 1
    else:
        print("No")
        exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    ans = [0] * n
    ans[0] = a[0]
    ans[1] = a[1]
    c[a[0]] -= 1
    c[a[1]] -= 1
    for i in range(2, n):
        v = ans[i - 1] ^ ans[i - 2]
        if c[v] > 0:
            ans[i] = v
            c[v] -= 1
        else:
            print("No")
            exit()
    for i in range(1, n - 1):
        if ans[i] != ans[i - 1] ^ ans[i + 1]:
            print("No")
            exit()
    if ans[n - 1] == ans[n - 2]^ans[0] and ans[0] == ans[1]^ans[n-1]:
        print("Yes")
    else:
        print("No")

            
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    ans = [0] * n
    ans[0] = a[0]
    ans[1] = a[1]
    #ans = ans + ans
    c[a[0]] -= 1
    c[a[1]]-=1
    for i in range(2, n):
        v = ans[i - 1] ^ ans[i - 2]
        #print(v,c[v])
        if c[v] > 0:
            ans[i] = v
            c[v] -= 1
        else:
            print("No")
            exit()
    if ans[n - 1] == ans[n - 2]^ans[0] and ans[0] == ans[1]^ans[n-1]:
        print("Yes")
    else:
        print("No")

            
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    ans = [0] * n
    ans[0] = a[0]
    ans[1] = a[1]
    #ans = ans + ans
    c[a[0]] -= 1
    c[a[1]]-=1
    for i in range(2, n):
        v = ans[i - 1] ^ ans[i - 2]
        print(v,c[v])
        if c[v] > 0:
            ans[i] = v
            c[v] -= 1
        else:
            print("No")
            exit()
    if ans[n - 1] == ans[n - 2]^ans[0] and ans[0] == ans[1]^ans[n-1]:
        print("Yes")
    else:
        print("No")

            
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] += 1

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] >= 1:
        ans[1] = (a[0] ^ a[i])
        ans[2] = a[i]
        table[ans[1]] -= 1
        table[ans[2]] -= 1
        break

if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] != i-2 and table[ans[i-1] ^ ans[i-2]] != i-1:
        ans[i] = ans[i-1] ^ ans[i-2]
        table[ans[i]] -= 1
    else:
        print("No")
        exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(_) for _ in input().split()]
s = set()
for i in range(N):
    s.add(a[i])
if len(s) == 1 and 0 in s:
    print('Yes')
else:
    if N%3 != 0 or len(s) != 3:
        print('No')
    else:
        cnt = []
        for x in s:
            cnt.append(a.count(x))
        if len(set(cnt)) != 1:
            print('No')
        else:
            xor = 0
            for x in s:
                xor ^= x
            if xor == 0:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(_) for _ in input().split()]
s = set()
for i in range(N):
    s.add(a[i])
if len(s) == 1 and 0 in s:
    print('Yes')
else:
    if N%3 != 0 or len(s) != 3:
        print('No')
    else:
        xor = 0
        for x in s:
            xor ^= x
        if xor == 0:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
from functools import reduce
n = int(input())
l = list(map(int, input().split()))
if n%3:
  if max(l) == 0:
    print("YES")
  else:
    print("NO")
else:
  if reduce((lambda x, y:x ^ y), l) == 0:
    print("YES")
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

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

b = list(Counter(a).items())
if sum(a) == 0:
    print("Yes")
    sys.exit()
    
if N % 3 == 0:
    if len(b) != 3:
        if len(b) == 2 and min(b[0][0], b[1][0]) == 0 and min(b[0][1], b[1][1]) == N // 3:
            print("Yes")
            sys.exit()
        print("No")
        sys.exit()
    c = [b[0][0], b[1][0], b[2][0], b[0][0], b[1][0]]
    for i in range(3):
        if c[i] != c[i+1] ^ c[i+2]:
            print("No")
            sys.exit()
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 3:
    a.append(a[0])
    a.append(a[1])
    for i in range(N):
        if a[i] != a[i+1] ^ a[i+2]:
            print("No")
            sys.exit()
    print("Yes")
else:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
n_bin = len(bin(max(a_ls))) - 2
a_ls = [bin(a)[2:].zfill(n_bin) for a in a_ls]
cnt = {i : 0 for i in range(n_bin)}
for a in a_ls:
    for i, _a in enumerate(a):
        cnt[i] += _a == "1"
flg = True
if sum(cnt.values()) == 0:
    print("Yes")
elif n % 3 != 0:
    print("No")
else:
    for i in range(n_bin):
        flg &= cnt[i] == n // 3 * 2
        if not flg:
            break
    if flg:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if set(A)=={0}:
  print('Yes')
elif len(set(A))==2:
  if A.count(A[0])==2*n/3 and A.count(0)==n/3:
    print('Yes')
elif len(set(A))==3:
  if A.count(list(set(A))[0])==n/3 and A.count(list(set(A))[1])==n/3 and A.count(list(set(A))[2])==n/3:
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

if set(A)=={0}:
  print('Yes')
elif A.count(A[0])==2*n/3 and A.count(0)==n/3:
  print('Yes')
elif len(set(A))==3:
  if A.count(list(set(A))[0])==n/3 and A.count(list(set(A))[1])==n/3 and A.count(list(set(A))[2])==n/3:
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
data=[]
lst=[a[0]]
num=1
for i in range(1,n):
    if a[i]==a[i-1]:
        num+=1
    else:
        data.append(num)
        lst.append(a[i])
        num=1
data.append(num)
if len(data)==3 and data[0]==data[1]==data[2]:
    if lst[0]^lst[1]==lst[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter as ct
import sys
input = sys.stdin.readline

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

if c[0] == n:
    print("Yes")
elif len(c) == 2 and c[0] * 3 == n:
    print("Yes")
elif len(c) == 3 and len(set(c.values())) == 1:
    a, b, c = c.keys()
    if a ^ b == c:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter as ct
import sys
input = sys.stdin.readline

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

if c[0] == n:
    print("Yes")
elif len(c) == 2 and c[0] * 3 == n:
    print("Yes")
elif len(c) == 3 and len(set(c.values())) == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter as ct
import sys
input = sys.stdin.readline

n = int(input())
a = input().split()
c = ct(a)

if c["0"] == n:
    print("Yes")
elif len(c) == 2 and c["0"] * 3 == n:
    print("Yes")
elif len(c) == 3 and c[0] ^ c[1] == c[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter as ct
import sys
input = sys.stdin.readline

n = int(input())
a = input().split()
c = ct(a)
if c["0"] == n:
    print("Yes")
elif len(c) == 2 and c["0"] * 3 == n:
    print("Yes")
elif len(c) == 3 and c[0] == c[1] and c[1] == c[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter as ct
import sys
input = sys.stdin.readline

n = int(input())
a = input().split()
c = ct(a)
print(c)
if c["0"] == n:
    print("Yes")
elif len(c) == 2 and c["0"] * 3 == n:
    print("Yes")
elif len(c) == 3 and c[0] == c[1] and c[1] == c[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
# 条件満たせるパターンは以下の3パターンある
# 全ての数字が0, 数字が2種類あって片方が0かつ0の個数がN//3, 数字が3種類あってx^y^z==0かつN//3個ずつ存在する
if len([a for a in A if a == 0]) == N:
    print("Yes")
    exit()

if N % 3 != 0:
    print("No")
    exit()

# Nが3の倍数であることが保証された
count = Counter(A)

if len(count.keys()) > 3:
    print("No")
    exit()
elif len(count.keys()) == 3:
    numbers = list(count.keys())
    amounts = list(count.values())
    if numbers[0] ^ numbers[1] ^ numbers[2] == 0 and amounts[0] == N//3 and amounts[1] == N//3 and amounts[2] == N//3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
elif len(count.keys()) == 2:
    numbers = list(count.keys())
    numbers.sort()
    amounts = list(count.values())
    if numbers[0] == 0 and count[0] == N//3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
if N % 3 != 0:
    print("No")
else:
    if len(count.keys()) == 3:
        for i in range(3):
            if list(count.values())[i] != N//3:
                print("No")
                break
        else:
            print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()

li += li

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))
if all([not i for i in a]):
  print("Yes")
else:
  if n % 3:
    print("No")
  else:
    print("Yes") #多分違う

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    st = set(A)

    A2 = list(st)
    if len(st) == 1:
        if A2[0] ^ A2[0] == A2[0]:
            print("Yes")
        else:
            print("No")
    elif len(st) == 3:
        if A2[0] ^ A2[1] == A2[2] and A2[1] ^ A2[2] == A2[0] and A2[2] ^ A2[0] == A2[1]:
            print("Yes")
        else:
            print("No")
    elif len(st) == 2:
        # 0, 0, 1
        if A[0] ^ A[1] in A:
            print("Yes")
        else:
            print("No")
    else:
        print("No")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    st = set(A)

    A2 = list(st)
    if len(st) != 3:
        print("No")
    elif A2[0] ^ A2[1] == A2[2] and A2[1] ^ A2[2] == A2[0] and A2[2] ^ A2[0] == A2[1]:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    st = set(A)

    A2 = list(st)
    if len(st) == 1 and st.pop() == 0:
        print("Yes")
    elif len(st) != 3:
        print("No")
    elif A2[0] ^ A2[1] == A2[2] and A2[1] ^ A2[2] == A2[0] and A2[2] ^ A2[0] == A2[1]:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if len(b) != 3:
    if sum(a) == 0:
        pass
    elif a.count(max(b)) == 2*n/3 and a.count(0) == n/3:
        pass
    else:
        print("No")
        exit()
else:
    if b[0] ^ b[1] == b[2] or a.count(b[0]) == a.count(b[1]) == a.count(b[2]):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
        
print("Yes")

Submission status: Wrong Answer

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

if len(b) != 3:
    if sum(a) == 0:
        pass
    elif a.count(max(b)) == 2*n/3 and a.count(0) == n/3:
        pass
    else:
        print("No")
        exit()
else:
    if b[0] ^ b[1] != b[2]:
        print("No")
        exit()
        
print("Yes")

Submission status: Wrong Answer

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

if len(b) != 3:
    if sum(a) == 0:
        pass
    elif a.count(max(b)) == 2*n/3 and a.count(0) == n/3:
        pass
    else:
        print("No")
        exit()
else:
    if b[0] ^ b[1] != b[2]:
        exit()
        
print("Yes")

Submission status: Wrong Answer

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

if n > 3:
    if sum(a) == 0:
        pass
    elif a.count(max(set(a))) == 2*n/3 and a.count(0) == n/3:
        pass
    else:
        print("No")
        exit()
else:
    if a[0] ^ a[1] != a[2]:
        exit()
print("Yes")

Submission status: Wrong Answer

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

if n > 3:
    if sum(a) == 0:
        pass
    elif sum(set(a)) == max(set(a)):
        pass
    else:
        print("No")
        exit()
else:
    if a[0] ^ a[1] != a[2]:
        exit()
print("Yes")

Submission status: Wrong Answer

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

if n > 3:
    print("No")
    exit()
else:
    if a[0] ^ a[1] == a[2]:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    a = collections.Counter(a).most_common()
    if len(a) == 1:
        if a[0][1] == 0:
            print("Yes")
        else:
            print("No")
    elif len(a) == 2:
        if a[0][1] == a[1][1] * 2 and a[1][0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(a) == 3:
        if a[0][0] ^ a[1][0] ^ a[2][0] == 0 and a[0][1] == a[1][1] == a[2][1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    solve()