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
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from collections import Counter

def main():
    N = i2n()
    A = i2nn()
    # 問題を数式化
    #   A[i-1] ^ A[i+1] = A[i] 
    # 移項する
    #   A[i-1] ^ A[i+1] - A[i] = 0
    #   A[i-1] ^ A[i+1] ^ A[i] = 0
    # 漸化式を考える
    #   A[i+1] = A[i-1] ^ A[i] 
    #   A[2] = A[0] ^ A[1] 
    # 漸化式をもう少し考える
    #   A[3] = A[1] ^ A[2] 
    #       A[1] ^ A[2] = A[0] なので
    #   A[3] = A[0]
    #   A[i+3] = A[i]
    # Nが3の倍数でないとき
    #   A[i] = A[j]
    #   A[i] ^ A[i+1] = A[i+2]
    #       A[i] = A[i+1] なので
    #   A[i+2] = 0
    #   よって, Aの要素は全てゼロ
    # Nが3の倍数のとき
    #   Counter 要素数=3, カウント値は全て同じ
    #   Aの要素が全てゼロでもok
    c = Counter(A)
    k = list(c.keys())
    v = list(c.values())
    if len(c) == 1:
        if 0 in c:
            print('Yes')
            return
    if len(c) == 3:
        if k[0] ^ k[1] ^ k[2] == 0:
            if v[0] == v[1] and v[1] == v[2]:
                print('Yes')
                return
    print('No')

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
flag = True
if max(a) == 0:   # 全て0の時は必ず成り立つ
    flag = True
else:
    if N % 3 != 0:   # 全て0でなくて，Nが3の倍数出ない時は成り立たない
        flag = False
    else:
        n = N // 3
        a_set = set(a)
        if len(a_set) == 2:
            count = [0] * 2
            for number in a_set:
                count.append(a.count(number))
            if count[0] == n and count[1] == n * 2:
                flag = True
            else:
                flag = False
        elif len(a_set) == 3:
            count = []
            value = []
            for number in a_set:
                count.append(a.count(number))
                value.append(number)
            if count[0] == count[1] == count[2]:
                if value[0] == value[1] ^ value[2] and value[1] == value[2] ^ value[0] and value[2] == value[0] ^ value[1]:
                    flag = True
                else:
                    flag = False
            else:
                flag = False
        else:
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from collections import Counter

def main():
    N = i2n()
    A = i2nn()
    # 問題を数式化
    #   A[i-1] ^ A[i+1] = A[i] 
    # 移項する
    #   A[i-1] ^ A[i+1] - A[i] = 0
    #   A[i-1] ^ A[i+1] ^ A[i] = 0
    # 漸化式を考える
    #   A[i+1] = A[i-1] ^ A[i] 
    #   A[2] = A[0] ^ A[1] 
    # 漸化式をもう少し考える
    #   A[3] = A[1] ^ A[2] 
    #       A[1] ^ A[2] = A[0] なので
    #   A[3] = A[0]
    #   A[i+3] = A[i]
    # Nが3の倍数でないとき
    #   A[i] = A[j]
    #   A[i] ^ A[i+1] = A[i+2]
    #       A[i] = A[i+1] なので
    #   A[i+2] = 0
    #   よって, Aの要素は全てゼロ
    # Nが3の倍数のとき
    #   Counter, 要素数=3, カウント値は全て同じ
    c = Counter(A)
    if N % 3 != 0:
        if len(c) == 1 and 0 in c:
            print('Yes')
            return
    else:
        if len(c) == 3:
            k = list(c.keys())
            v = list(c.values())
            if k[0] ^ k[1] ^ k[2] == 0:
                if v[0] == v[1] and v[1] == v[2]:
                    print('Yes')
                    return
    print('No')

main()

Submission status: Wrong Answer

Solution code:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from collections import Counter

def main():
    N = i2n()
    A = i2nn()
    # 問題を数式化
    #   A[i-1] ^ A[i+1] = A[i] 
    # 移項する
    #   A[i-1] ^ A[i+1] - A[i] = 0
    #   A[i-1] ^ A[i+1] ^ A[i] = 0
    # 漸化式を考える
    #   A[i+1] = A[i-1] ^ A[i] 
    #   A[2] = A[0] ^ A[1] 
    # 漸化式をもう少し考える
    #   A[3] = A[1] ^ A[2] 
    #       A[1] ^ A[2] = A[0] なので
    #   A[3] = A[0]
    #   A[i+3] = A[i]
    # Nが3の倍数でないとき
    #   A[i] = A[j]
    #   A[i] ^ A[i+1] = A[i+2]
    #       A[i] = A[i+1] なので
    #   A[i+2] = 0
    #   よって, Aの要素は全てゼロ
    # Nが3の倍数のとき
    #   Counter, 要素数=3, カウント値は全て同じ
    c = Counter(A)
    if N % 3 != 0:
        if len(c) == 1 and 0 in c:
            print('Yes')
            return
    else:
        if len(c) == 3:
            v = list(c.values())
            if v[0] == v[1] and v[1] == v[2]:
                print('Yes')
                return
    print('No')

main()

Submission status: Wrong Answer

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

a = list(set(A))

ans = "No"

if a == [0]:
    ans = "Yes"
elif len(a) == 2:
    if a[0] == 0 or a[1] == 0 and N % 3 == 0 and A.count(0) == N//3:
        ans = "Yes"
elif len(a) == 3:
    if a[0] ^ a[1] == a[2] and N % 3 == 0 and A.count(a[0]) == A.count(a[1]) == N//3:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

a = list(set(A))

ans = "No"

if len(a) == 1:
    if a == [0]:
        ans = "Yes"
elif len(a) == 2:
    if N % 3 == 0 and A.count(0) == N//3:
        ans = "Yes"
elif len(a) == 3:
    if N % 3 == 0 and (A.count(a[0]),A.count(a[1]),A.count(a[2])) == (N//3,N//3,N//3):
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

ans = "No"

if a == [0]:
    ans = "Yes"
elif len(a) == 3:
    if a[0] ^ a[1] == a[2] and N % 3 == 0 and A.count(a[0]) == A.count(a[1]) == N//3:
        ans = "Yes"
elif len(a) == 2:
    if a[0] == 0 or a[1] == 0 and N % 3 == 0 and A.count(0) == N//3:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

ans = "No"

if a == [0]:
    ans = "Yes"
elif len(a) == 3:
    if a[0] ^ a[1] == a[2] and N % 3 == 0 and A.count(A[0]) == A.count(A[1]) == N//3:
        ans = "Yes"
elif len(a) == 2:
    if a[0] == 0 or a[1] == 0 and N % 3 == 0 and A.count(0) == N//3:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
def intinput():return map(int,input().split())

import itertools
n=int(input())
a=list(intinput())
t=set(a)
if n%3!=0:
    if t=={0}:
        print("Yes")
    else:
        print("No")
    sys.exit()
if len(t)>3:
    print("No")
else:
    for i in itertools.product(tuple(t),repeat=3):
        if i[-2]^i[-1]^i[0]==0 and i[-1]^i[0]^i[1]==0 and i[0]^i[1]^i[2]==0:
            break
    else:
        print("No")
        sys.exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

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

    c = Counter(A)
    if N % 3 == 0:
        # All caps are 0.
        if 0 in c and len(c) == 1:
            return 'Yes'

        # N/3 '0', and 2N/3 'non-zero'.
        if 0 in c and len(c) == 2:
            v0 = c[0]
            for k, v in c.items():
                if k != 0 and v == 2 * v0:
                    return 'Yes'

        # Three caps.
        if len(c) == 3:
            keys = []
            for k in c.keys():
                keys.append(k)

            x, y, z = keys[0], keys[1], keys[2]
            if (x ^ y) == z and c[x] == c[y] == c[z]:
                return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

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

    c = Counter(A)
    if N % 3 == 0:
        # All caps are 0.
        if 0 in c and len(c) == 1:
            return 'Yes'

        # N/3 '0', and 2N/3 'non-zero'.
        if 0 in c and len(c) == 2:
            v0 = c[0]
            for k, v in c.items():
                if k != 0 and v == 2 * v0:
                    return 'Yes'

        # Three caps.
        if len(c) == 3:
            keys = []
            for k in c.keys():
                keys.append(k)

            x, y, z = keys[0], keys[1], keys[2]
            if x^y == z and c[x] == c[y] == c[z]:
                return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

if N%3:
    ans = True
    for a in A:
        if a:ans=False;break
else:
    B = set(A)
    l = len(B)
    ans = True
    if l>3 or l==2:ans = False
    elif l==1:
        for b in B:
            if b:ans=False;break
    else:
        a,b,c = B
        ans = ans and (A.count(a)==A.count(b)==A.count(c)==N//3) and (a^b==c)
        
if ans:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int, input().split())))
frag=False
if n % 3 != 0 and (not sum(a)==0): frag=False
else:
    if (a[1]==a[2]) and a[0] == 0: frag=True
    if (a[2]-a[1])==a[0]:
      if a[1]%n != 0:
        frag=True
      else:
        if (a[1]//n)%2==0:
          frag=True
        if sum(a)==0: frag=True
        if (a[2]-a[1])==(a[1]-a[0])==1: frag=True

print("Yes" if frag else "No")

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
A=[int(x) for x in input().split()]
AA=sorted(A)
c=collections.Counter(A)
third=N//3
answer="No"

#文字が全部0
if all(a==0 for a in A):
  answer="Yes"

#0aa0aaという並びに出来る
#0がN/3個,aが2N/3個で数字は二種類
elif len(c)==2 and N%3==0:
  if all(a in AA[:third]==0 for a in AA[:third]):
    answer="Yes"
     
#abc,abc...,abcという並びに出来る
#aがN/3個,bがN/3個,cがN/3個で数字は三種類
elif len(c)==3 and N%3==0:
  if A.count(AA[0])==third and \
  A.count(AA[third])==third and \
  A.count(AA[2*third])==third:
    if bin(AA[0]^AA[third])==bin(AA[2*third]) and \
    bin(AA[third]^AA[2*third])==bin(AA[0]) and \
    bin(AA[2*third]^AA[0])==bin(AA[third]):
      answer="Yes"
    
print(answer)

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
A=[int(x) for x in input().split()]
AA=sorted(A)
c=collections.Counter(A)
third=N//3
answer="No"

#文字が全部0
if all(a==0 for a in A):
  answer="Yes"

#0aa0aaという並びに出来る
#0がN/3個,aが2N/3個で数字は二種類
elif len(c)==2 and N%3==0:
  if all(a in AA[:third]==0 for a in AA):
    answer="Yes"
     
#abc,abc...,abcという並びに出来る
#aがN/3個,bがN/3個,cがN/3個で数字は三種類
elif len(c)==3 and N%3==0:
  if A.count(AA[0])==third and \
  A.count(AA[third])==third and \
  A.count(AA[2*third])==third:
    if bin(AA[0]^AA[third])==bin(AA[2*third]) and \
    bin(AA[third]^AA[2*third])==bin(AA[0]) and \
    bin(AA[2*third]^AA[0])==bin(AA[third]):
      answer="Yes"
    
print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ret = 'No'
c = Counter(A)
if all([i == 0 for i in c]):
    ret = 'Yes'
else:
    v = set(list([i[1] for i in c.items()]))
    if len(c) == 3 and 0 not in c and all([i == N/3 for i in v]):
        ret = 'Yes'
    elif len(c) == 2 and 0 in c:
        for i in c.items():
            if i[0] == 0 and i[1] == N/3:
                ret = 'Yes'

print(ret)

Submission status: Wrong Answer

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

c = Counter(a)
keys = sorted(list(c.keys()))
values = sorted(list(c.values()))
if N % 3 != 0:
    print("No")
    exit()
if len(keys) == 1 and keys[0] == 0:
    print("Yes")
elif len(keys) == 2 and 0 in keys and c[0] == N//3:
    print("Yes")
elif len(keys) == 3 and values[0] == values[1] == values[2] == N//3 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()))

c = Counter(a)
keys = sorted(list(c.keys()))
values = sorted(list(c.values()))
if N % 3 != 0:
    print("No")
    exit()
if len(keys) == 1 and keys[0] == 0:
    print("Yes")
elif len(keys) == 2 and keys[0] == 0 and values[0] == N//3:
    print("Yes")
elif len(keys) == 3 and values[0] == values[1] == values[2] == N//3 and keys[0] ^ keys[1] ^ keys[2] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
print(all(a[i-1] ^ a[i+1-N] == a[i] for i in range(N)) and 'Yes' or 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ret = 'No'
c = Counter(A)
if all([i == 0 for i in c]):
    ret = 'Yes'
else:
    v = set(list([i[1] for i in c.items()]))
    if len(c) == 3 and all([i == N/3 for i in v]):
        ret = 'Yes'
    elif len(c) == 2 and 0 in c:
        for i in c.items():
            if i[0] == 0 and i[1] == N/3:
                ret = 'Yes'

print(ret)

Submission status: Wrong Answer

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

uni = list(set(a))
if len(uni) == 1 and uni[0] == 0:
    print("Yes")
elif len(uni) == 2 and 0 in uni:
    print("Yes")
elif len(uni) == 3 and uni[0] ^ uni[1] ^ uni[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()))
ret = 'No'
c = Counter(A)
if all([i == 0 for i in c]):
    ret = 'Yes'
else:
    v = set(list([i[1] for i in c.items()]))
    if all([i == N/3 for i in v]):
        ret = 'Yes'
    elif len(c) == 2 and 0 in c:
        for i in c.items():
            if i[0] == 0 and i[1] == N/3:
                ret = 'Yes'

print(ret)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ret = 'No'
c = Counter(A)
if all([i == 0 for i in c]):
    ret = 'Yes'
else:
    v = set(list([i[1] for i in c.items()]))
    if all([i == N//3 for i in v]):
        ret = 'Yes'
    elif len(c) == 2 and 0 in c:
        for i in c.items():
            if i[0] == 0 and i[1] == N//3:
                ret = 'Yes'

print(ret)

Submission status: Wrong Answer

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

tmp = set()
for a in a_list:
    tmp.add(a)

if a_list.count(0) == N:
    print("Yes")
else:
    if len(tmp) == 2 and a_list.count(0) == N // 3:
        print("Yes")
    elif len(tmp) == 3 and a_list.count(0) == 0:

        b = list(tmp)
        if b[0] ^ b[1] == b[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ret = 'No'
c = Counter(A)
# for i in c.items():
#     print(i)
if all([i == 0 for i in c]):
    ret = 'Yes'
else:
    v = set(list([i[1] for i in c.items()]))
    if len(c) == 3:
        if len(v) == 1:
            ret = 'Yes'
    elif len(c) == 4:
        cnt = []
        for i in c.items():
            if i[0] != 0:
                cnt.append(i[1])
        if len(set(cnt)) == 1:
            ret = 'Yes'
print(ret)

Submission status: Wrong Answer

Solution code:
from collections import Counter


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


def main():
    if all(map(lambda e: e == 0, a)):
        print('Yes')
        return

    if n % 3 != 0:
        print('No')
        return

    count = dict(Counter(a))
    keys = list(count.keys())
    values = list(count.values())

    if len(count) == 3:
        if values[0] == values[1] and values[1] == values[2] and (keys[0] ^ keys[1] ^ keys[2]) == 0:
            print('Yes')
        else:
            print('No')
    # a, a, 0, ...
    elif len(count) == 2:
        if 0 not in count:
            print('No')
        elif (2 * count[0]) == max(values):
            print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter


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


def main():
    if all(map(lambda e: e == 0, a)):
        print('Yes')
        return

    if n % 3 != 0:
        print('No')
        return

    count = dict(Counter(a))
    if len(count) == 3:
        keys = list(count.keys())
        values = list(count.values())
        if values[0] == values[1] and values[1] == values[2] and (keys[0] ^ keys[1] ^ keys[2]) == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter


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

if n % 3 != 0:
    if all(map(lambda e: e == 0, a)):
        print('Yes')
    else:
        print('No')

else:
    count = dict(Counter(a))
    if len(count) == 3:
        keys = list(count.keys())
        values = list(count.values())
        if values[0] == values[1] and values[1] == values[2] and (keys[0] ^ keys[1] ^ keys[2]) == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter


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

if n % 3 != 0:
    if all(map(lambda e: e == 0, a)):
        print('Yes')
    else:
        print('No')

else:
    count = dict(Counter(a))
    if len(count) == 3:
        values = list(count.values())
        if values[0] == values[1] and values[1] == values[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *a = map(int, open(0).read().split())

cnt = 0
for v in set(a):
    cnt ^= v

ctr = Counter(a)
flg1 = sum(a) == 0
flg2 = len(ctr) == 2 and ctr[0] == 3 / N
flg3 = cnt == 0 and len(ctr) == 3 and all(v == 3 / N for v in ctr.values())
print('Yes' if flg1 or flg2 or flg3 else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *a = map(int, open(0).read().split())

cnt = 0
for v in set(a):
    cnt ^= v

ctr = Counter(a)
flg1 = sum(a) == 0
flg2 = len(ctr) == 2 and ctr[0] == 3 // N
flg3 = cnt == 0 and len(ctr) == 3 and all(v == 3 // N for v in ctr.values())
print('Yes' if flg1 or flg2 or flg3 else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *a = map(int, open(0).read().split())

cnt = 0
for v in set(a):
    cnt ^= v

ctr = Counter(a)
flg1 = sum(a) == 0
flg2 = len(ctr) == 2 and ctr[0] == 3 // N
flg3 = v == 0 and len(ctr) == 3 and all(v == 3 // N for v in ctr.values())
print('Yes' if flg1 or flg2 or flg3 else 'No')

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[ (i-1+N) % N ]
        a2 = A[ (i+0+N) % N ]
        a3 = A[ (i+1+N) % N ]
        if a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, *a = map(int, open(0).read().split())

ctr = Counter(a)
flg1 = sum(a) == 0
flg2 = len(ctr) == 2 and ctr[0] == 3 // N
flg3 = len(ctr) == 3 and all(v == 3 // N for v in ctr.values())
print('Yes' if flg1 or flg2 or flg3 else 'No')

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[ (i-1+N) % N ]
        a2 = A[ (i+0+N) % N ]
        a3 = A[ (i+1+N) % N ]
        if a1 != a2 and a2 != a3 and a3 != a1 and a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
    
    check = False
    for i in range(N):
        a1 = A[ (i-1+N) % N ]
        a2 = A[ (i+0+N) % N ]
        a3 = A[ (i+1+N) % N ]
        a4 = A[ (i+2+N) % N ]

        if a1 != a4:
            check = False
            break
            
        if a1 == a2 and a3 == 0:
            check = True
        elif a2 == a3 and a1 == 0:
            check = True
        elif a3 == a1 and a2 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[ (i-1+N) % N ]
        a2 = A[ (i+0+N) % N ]
        a3 = A[ (i+1+N) % N ]
        if a1 != a2 and a2 != a3 and a3 != a1 and a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
    
    check = False
    for i in range(N):
        a1 = A[ (i-1+N) % N ]
        a2 = A[ (i+0+N) % N ]
        a3 = A[ (i+1+N) % N ]
        if a1 == a2 and a3 == 0:
            check = True
        elif a2 == a3 and a1 == 0:
            check = True
        elif a3 == a1 and a2 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1 != a2 and a2 != a3 and a3 != a1 and a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
    
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1 == a2 and a3 == 0:
            check = True
        elif a2 == a3 and a1 == 0:
            check = True
        elif a3 == a1 and a2 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve(N, As):
    c = Counter(As)
    if len(c) == 1:
        return "Yes"
    if len(c) == 3 and c[0] == c[1] == c[2]:
        return "Yes"
    return "No"


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))

Submission status: Wrong Answer

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

c = collections.Counter(a)
key = list(c.keys())
if (c[0] == n or (len(key)==2 and c[0] == n/3) or (len(key)==3 and (key[0] ^ key[1] ^ key[2]) == 0)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1 != a2 and a2 != a3 and a3 != a1 and a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
        check = False
    
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1 == a2 and a3 == 0:
            check = True
        elif a2 == a3 and a1 == 0:
            check = True
        elif a3 == a1 and a2 == 0:
            check = True
        else:
            check = False
            break

    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1 != a2 and a2 != a3 and a3 != a1 and a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
        check = False
    
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1 == a2 and a3 == 0:
            check = True
        elif a2 == a3 and a1 == 0:
            check = True
        elif a3 == a1 and a2 == 0:
            check = True
        else:
            check = False
            break

    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N):
        a1 = A[i]
        a2 = A[ (i+1+N) % N ]
        a3 = A[ (i+2+N) % N ]
        if a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

if a.count(0)==n:
    print('Yes')
elif n%3==0:
    if a.count(0)==n//3 and a.count(a[n//3])==n//3*2:
        print('Yes')
    elif a.count(0)==n//3 and a.count(a[n//3])==n//3 and a.count(a[n//3*2])==n//3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

if a.count(0)==n:
    print('Yes')
elif n%3==0:
    if a.count(0)==n/3 and a.count(a[n//3])==n/3*2:
        print('Yes')
    elif a.count(0)==n/3 and a.count(a[n//3])==n/3 and a.count(a[n//3*2])==n/3:
        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:
    check = False
    for i in range(N-1):
        a1 = A[i]
        a2 = A[i+1]
        a3 = A[ (i+2+N) % N ]
        if a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
else:
    check = False
    for i in range(N):
        if A[i] == 0:
            check = True
        else:
            check = False
    if check:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

if N % 3 == 0:
    check = False
    for i in range(N-1):
        a1 = A[i]
        a2 = A[i+1]
        a3 = A[ (i+2+N) % N ]
        if a1^a2^a3 == 0:
            check = True
        else:
            check = False
            break
    if check:
        print("Yes")
        exit()
        
print("No")