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:
N = int(input())
a = list(map(int,input().split(" ")))
a_map = {}
for i in a:
    a_map[i] = 1
kouho = a[1:]
def findOne(chain,kouho):
    if len(kouho) == 0:
        return True
    last = chain
    for j in kouho:
        if last^j in a_map and a_map[(last^j)] == 1:
            a_map[j] = 2
            a_map[(last^j)] = 2
            ret = findOne(j,list(set(kouho)-set([j,last^j])))
            if ret:
                return True
            a_map[j] = 1
            a_map[(last^j)] = 1
    return False
a_map[a[0]] = 2
res = findOne(a[0],kouho)
if res:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
arr=[]
for i in range(0,N+1):
    LF=(i-1)%N if (i-1) > (N-1) else (i-1)
    RI=(i+1)%N if (i+1) > (N-1) else (i+1)
    MI=i%N if i > (N-1) else i
    aaa = str(int(bin(A[LF]).split("b")[1])+int(bin(A[RI]).split("b")[1]))
    bbb = "".join(list(map(lambda x:str(int(x)%2),aaa)))
    arr.append(int(bbb)==int(bin(A[MI]).split("b")[1]))

print("Yes" if all(arr) else "No")

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(N):
    if i == 0:
        a = bin(a_list[N-1])
        b = bin(a_list[i+1])
    elif i == N-1:
        a = bin(a_list[i-1])
        b = bin(a_list[0])
    else:
        a = bin(a_list[i-1])
        b = bin(a_list[i+1])
    c = int(a, 0) ^ int(b, 0)
    if c != a_list[i]:
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    a = list(map(int, input().split()))
    for i in range(1, N-1, 1):
        if not a[i-1] ^ a[i+1] == i+1:
            print("No")
            exit()
    if not a[N-2] ^ a[0]  == N:
        print("No")
        exit()
    elif not a[N-1] ^ a[1] == 1:
        print("No")
        exit()
    print("Yes")

    # print(a[1] ^ a[2], a[0] ^ a[2], a[0] ^ a[1])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*31+bin(int(x))[2:])[-30:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())
    if len(keys)>3:
        return 'No'
    if len(keys)==1:
        if "1" in keys[0]:
            return 'No'
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'
        
        if vals[0]==vals[1]*2 or vals[0]*2==vals[1]:
            return 'Yes'
        return 'No'
    if len(ALC.keys())==3:
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())

Submission status: Wrong Answer

Solution code:
from collections import Counter

# s = input()
N = int(input())
A = list(map(int, input().split()))
# a, b = map(int, input().split())

c = Counter()

for a in A:
    c[a] += 1

k = list(c.keys())
v = list(c.values())
if len(v) == 1:
    if k[0]^k[0] == k[0]:
        print("Yes")
        exit()

print(k, v)

if len(v) == 2 and N%3 == 0:
    if v[0]*2 == v[1]:
        if k[1]^k[1] == k[0]:
            print("Yes")
            exit()
    if v[1]*2 == v[0]:
        if k[0]^k[0] == k[1]:
            print("Yes")
            exit()


if len(v) == 3:
    if v[0] == v[1] and v[1] == v[2]:
        if k[0]^k[1] == k[2]:
            print("Yes")
            exit()

print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
cnt = Counter(l)
res = False
if n == 3:
    res = l[0] ^ l[2] == l[1]
elif len(cnt) == 1: res = True
elif (n & 1) and len(cnt) == 2:
    if cnt[l[0]] in (n // 2, n // 2 + 1):
        res = l[0] ^ l[2] == l[1]
print("Yes" if res else "No")

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = [int(i) for i in input().split()] 
# n=3
# a=[1,2,3]
for i in range(n-1):
#     print(i,i+1)
    if not(a[i-1] ^ a[i+1] == a[i]):
        print('No')
        sys.exit(0)
if not(a[i] ^ a[0] == a[i+1]):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]

input_size = len(input_num)-1
for i in range(len(input_num)-1):
    left = i-1
    right = i+1
    if left < 0:
        left = input_size
    if right <= input_size:
      right = 0
#     print(input_num[left])
#     print(input_num[right])
    if input_num[left]^input_num[right] == input_num[i]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
candidates = list(set(As))

if len(candidates) > 3 or len(candidates) == 1:
    print('No')
elif len(candidates) == 2:
    if 0 in candidates:
        a, z = candidates
        if z == 0:
            a, z = z, a

        bits = format(z, '0b')

        if bits.find('0') == -1:
            count_a = 0
            count_z = 0
            for element in As:
                if element == 0:
                    count_z += 1
                else:
                    count_a += 1
            else:
                if count_a == count_z:
                    print('Yes')
                else:
                    print('No')
        else:
            print('No')
    else:
        print('No')
# len(candidates) == 3
else:
    a, b = candidates[:-1]
    c = candidates[-1]
    if a ^ b != c:
        print('No')
    else:
        count_a = 0
        count_b = 0
        count_c = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == b:
                count_b += 1
            else:
                count_c += 1
        else:
            if count_a == count_b and count_b == count_c:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[0]
y = a[N // 3]
z = a[- N // 3]
if a[-1] == 0:
	print('Yes')
else:
	if N % 3 == 0:
		if a[N // 3 - 1] == 0 and y == 1 and a[-1] == 1:
			print('Yes')
		else:
			if a.count(x) == N // 3 and a.count(y) == N // 3 and a.count(z) == N // 3: 
				if x ^ y == z and y ^ z == x and z ^ x == y:
					print('Yes')
				else:
					print('No')
			else:
				print('No')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

num = []
for k in a:
    if k not in num:
        num.append(k)
    if len(num) > 3:
        print('No')
        exit()
if len(num) == 1 and num[0] ^ num[0] == 0:
    print('Yes')
    exit()
if len(num) == 2 and num[0] ^ num[1] == num[0] and N % 2 == 0:
    print('Yes')
    exit()
if len(num) <= 2:
    print('No')
    exit()
if num[0] ^ num[1] != num[2] and num[2] ^ num[1] != num[0] and num[0] ^ num[2] != num[1] and N % 3 == 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

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

x = 0
y = 0
z = 0

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

else:

  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()

  if x != 0 and y != 0 and z != 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
res = []
for n in range(len(a)):
  if(n == (len(a) - 1)):
    res.append(a[n - 1]^a[0])
  else:
    res.append(a[n - 1]^a[n + 1])
for i, j in enumerate(res):
  if(i+1 != j):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=set(a)
l=len(b)
if l==2:
  c=sorted([b.pop(),b.pop()])
  if c[1]^c[0]==c[1]:
    if n%2==0 and a[n//2-1]!=a[n//2]:print("Yes")
    else:print("No")
  else:print("No")
  exit()
elif l==1:
  if a[0]==0:print("Yes")
  else:print("No")
  exit()
def ecount(X):
  c,ans=1,[]
  for i in range(len(X)-1):
    if X[i]==X[i+1]:c+=1
    else:
      ans.append(c);c=1
  ans.append(c)
  return ans
for i in range(n):
  if a[i]!=0:d=ecount(a[i:]);z=i;break
if l-(0 in b)!=3:print("No");exit()
if 0 in b:b.discard(0)
for i in range(z):
  d.sort()
  d[-1]-=1
d.sort()
if d[0]>0 and b.pop()^b.pop()^b.pop()==0 and d[0]==d[2]:print("Yes")
else:print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from random import shuffle
n = int(input())
lst = list(map(int,input().split()))
flg = 1
for j in range(10):
  for i in range(len(lst)):
    if i+1 == len(lst):
      if bin(lst[i]) != bin(lst[i-1] ^ lst[0]):
        flg = 0
        break
    elif bin(lst[i]) != bin(lst[i-1] ^ lst[i+1]):
      flg = 0
      break
    shuffle(lst)
if flg == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=long(raw_input())
a=sorted(map(long, raw_input().split()))

if n % 3 != 0:
    print "No"
else:
    if len(set(a[0:n/3])) == 1 and len(set(a[n/3:n/3*2])) == 1 and len(set(a[n/3*2:n])) == 1:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
def solve():
    num = int(input())
    camels = [int(i) for i in input().split()]

    if len(camels) % 3 != 0:
        print("No")
        return(0)

    camels.sort()
    length = len(camels)

    for i in range(3):
        for j in range(int(i*length/3), int((i+1)*length/3)):
            if camels[int(i*length/3)] != camels[j]:
                print("No")
                return(0)

    if camels[0] ^ camels[int(num/3)] != camels[int(num/3)*2]:
        print("No")
        return(0)

    print("Yes")

solve()

Submission status: Wrong Answer

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

c = collections.Counter(a)
k = list(c.keys())
v = list(c.values())

if n % 3 == 0:
  if len(v) == 3:
    if v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
      print("Yes")
    else:
      print("No")
  elif len(v) == 2:
    if (k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0]):
      print("Yes")
    else:
      print("No")
  elif len(v) == 1:
    if k[0] == 0:
      print("Yes")
    else:
      print("No")
elif len(v) == 1:
  if k[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()))

flag1 = True
flag2 = True

for i in a:
    if a != 0:
        flag1 = False
        break

if not flag1:
    if n % 3 != 0:
        flag2 = False
    if flag2:
        a.sort()
        a11 = a[0: n // 3]
        a12 = a[n // 3: 2 * n // 3]
        a13 = a[2 * n // 3:]
        if not (a11.count(a11[0]) == a12.count(a12[0]) == a13.count(a13[0])):
            flag2 = False
    if flag2:
        a1, a2, a3 = a[0], a[n // 3], a[2 * n // 3]
        aa = [[], [], []]
        for i in range(30):

            aa[0].append(a1 % 2)
            aa[1].append(a2 % 2)
            aa[2].append(a3 % 2)
            a1 = a1 // 2
            a2 = a2 // 2
            a3 = a3 // 2

        for i in range(30):
            if aa[0][i] == 0 and aa[1][i] == 0 and aa[2][i] == 1:
                flag2 = False
                break
            if aa[0][i] == 0 and aa[1][i] == 1 and aa[2][i] == 0:
                flag2 = False
                break
            if aa[0][i] == 1 and aa[1][i] == 0 and aa[2][i] == 0:
                flag2 = False
                break
            if aa[0][i] == 1 and aa[1][i] == 1 and aa[2][i] == 1:
                flag2 = False
                break


if flag1 or flag2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*31+bin(int(x))[2:])[-4:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())
    if len(keys)>3:
        return 'No'
    if len(keys)==1:
        if "1" in keys[0]:
            return 'No'
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'
        
        if vals[0]==vals[1]*2 or vals[0]*2==vals[1]:
            return 'Yes'
        return 'No'
    if len(ALC.keys())==3:
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=[]
l.append(a[0])
for i in range(1,n):
    if a[i]^a[0] in a:
        x=a[i]^a[0]
        l.append(a[i])
        l.append(x)
        a.remove(a[i])
        a.remove(x)
        break
if n==3:
    if len(l)==3:
        print("Yes")
    else:
        print("No")
else:
    if len(l)!=3:
        print("No")
        exit()
    for i in range(3,n):
        if l[i-2]^l[i-1] in a:
            x=l[i-2]^l[i-1]
            l.append(x)
            a.remove(x)
        else:
            print("No")
            exit()
    if len(l)==n and l[0]^l[1]==l[-1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a = LI()

    from collections import Counter

    cnt = Counter(a)

    if len(cnt) == 1 and a[0] == 0:  # all elements are zero
        print('Yes')
        return
    

    if len(cnt) == 3:
        x, y, z = cnt.keys()
        if x^y==z and y^z==x and z^x==y:
            print('Yes')
            return
    print('No')




main()

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    aa = list(map(int, input().split()))

    flg = len(aa) % 3 == 0

    tmp1 = aa[0]
    tmp2 = aa[1]
    tmp3 = aa[2]

    if flg:
        flg = tmp1 == tmp2 ^ tmp3 and tmp2 == tmp1 ^ tmp3 and tmp3 == tmp1 ^ tmp2

    if flg:
        for a1,a2,a3 in zip(aa,aa[1:],aa[2:]):
            if not(a1 == tmp1 and a2 == tmp2 and a3 == tmp3):
                flg = False
                break

    print('Yes' if flg else 'No')
    
resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
first = 0
pattern = True
for i in range(1,len(A)):
    last = i
    next = A[first] ^ A[last]
    # print(next)
    if next in A:
        first = last
        last = A.index(next)
    else:
        pattern = False
        break

if pattern == False:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a_n = [int(i) for i in input().split()]


is_yes = False

a_n_unique = list(set(a_n))

if len(a_n_unique) == 1:
    if a_n_unique[0] == 0:
        is_yes = True

if N % 3 == 0:
    if len(a_n_unique) == 2:
        if a_n_unique[0] == 0 or a_n_unique[1] == 0:
            if a_n.count(a_n_unique[0]) > a_n.count(a_n_unique[1]):
                if a_n.count(a_n_unique[0]) / a_n.count(a_n_unique[1]) ==2:
                    is_yes = True
            else:
                if a_n.count(a_n_unique[1]) / a_n.count(a_n_unique[0]) ==2:
                    is_yes = True
    elif len(a_n_unique) == 3:
        if a_n_unique[0] ^ a_n_unique[1] == a_n_unique[2]:
            is_yes = True


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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



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


    import itertools
    A="123456"
    for p in itertools.permutations(A):
        print(p)
    exit()


    import itertools
    for p in itertools.permutations(A):
        if p[0]!=A[0]:
            print("No")
            exit()
        else:
            out=True
            for i in range(N):
                if i==0:
                    last=N-1
                else:
                    last=i-1
                if i==N-1:
                    ne=0
                else:
                    ne=i+1
                # print(last,ne)
                if p[last]^p[ne]!=p[i]:
                    out=False
                    break
            if out:
                print("Yes")
                exit()
                        # exit()

        # print(p)
        # if p[0]!='A': continue
    # for i in range(N):
    #     if i==0:
    #         last=N-1
    #     else:
    #         last=i-1
    #     if i==N-1:
    #         ne=0
    #     else:
    #         ne=i+1
    #     print(last,ne)
    #     if A[last]^A[ne]!=A[i]:
    #         print("No")
    #         # exit()
    # print("Yes")

    # A.append(A[0])
    # A.append(A[1])
    # for i in range(1,N+1):
    #     # print(i-1,i+1)
    #     if A[i-1]^A[i+1]!=A[i]:
    #         print("No")
    #         exit()
    # print("Yes")

    # print(A,B)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
a = input().split()

for i in range(N):
	x = int(a[(i-1)%N])
	y = int(a[(i+1)%N])

	if int(a[i%N]) != x^y:
		print('No')
		sys.exit(0);

print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
cnt = Counter(l)
res = False
if n == 3:
    res = l[0] ^ l[1] == l[2]
elif len(cnt) == 1: res = True
elif (n & 1) and len(cnt) == 2:
    if cnt[l[0]] in (n // 2, n // 2 + 1):
        res = l[0] ^ l[1] == l[2]
print("Yes" if res else "No")

Submission status: Wrong Answer

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

ret_list = []
ret_list.append(a_list.pop(0))
ret_list.append(a_list.pop(0))

flag = True
while True:
    for_end = False
    ret_len = len(ret_list)
    mid_v = ret_list[ret_len-1]
    left_v = ret_list[ret_len-2]
    a_len = len(a_list)

    if a_len != 0:
        for i in range(a_len):
            tmp_right_v = a_list[i]
            side = left_v ^ tmp_right_v
            if side == mid_v:
                ret_list.append(a_list.pop(i))
                break

            if i == a_len-1:
                flag = False
    else:
        side = left_v ^ ret_list[0]
        if side != mid_v:
            flag = False
        else:
            break

    if not flag:
        break

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

B = set(A)
if N%3 == 0:
    C = list(B)
    ans = 0
    for i in range(N):
        ans = ans^A[i]

    if ans == 0:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

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

ret = 0
for i in range(n):
    ret ^= (i + 1)
    if a[i] == 0:
        print('No')
        exit()
    ret ^= a[i]

print('Yes' if ret == 0 else 'No')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
a = list(map(int, input().split()))
a.append(a[0])

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

    else:
        if bin(a[i-1] ^ a[i+1]) == bin(a[i]):
            continue
        else:
            print("No")
            sys.exit()

print("Yes")

Submission status: Wrong Answer

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

xor = []

for i in range(N):
  if i != (N-1) and i != (N-2):
    xor.append(an[i]^an[i+2])
  else:
    xor.append(an[i]^an[i-(N-2)])
    
for i in range(N):
  if an[i] in xor:
    xor.remove(an[i])

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

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
a=list(map(int,input().split()))
def judge(a):
    if sum(a)==0:
        return True
    else:
        a=dict(collections.Counter(a))
        if len(a.keys())==3:
            a0=list(a.keys())[0]
            a1=list(a.keys())[1]
            a2=list(a.keys())[2]
            if a0^a1==a2 and a[a0]==a[a1] and a[a1]==a[a2]:
                return True
    return False

if judge(a):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

INF = 10**9+7
PRIME_NUM = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def main():
	n = int(input())
	a = list(map(int,input().split()))
	a.sort()
	b=[]
	for i in range(0,int(n/2)):
		b.append(a[i*2])
	if(n%2!=0):
		b.append(a[n-1])
	for i in reversed(range(int(n/2)+n%2,n)):
		tmp=(n-i)*2
		b.append(a[tmp-1])
	flag=True
	for i in range(n):
		if(i==0):
			if(b[-1]^b[1]!=b[0]):
				flag=False
		elif(i==(n-1)):
			if(b[-2]^b[0]!=b[-1]):
				flag=False
		else:
			if(b[i-1]^b[i+1]!=b[i]):
				flag=False
	if flag:
		print('Yes')
	else:
		print('No')


main()

Submission status: Wrong Answer

Solution code:
def solve():
    num = int(input())
    camels = [int(i) for i in input().split()]

    if len(camels) % 3 != 0:
        print("no")
        return(0)

    camels.sort()
    length = len(camels)

    for i in range(3):
        for j in range(int(i*length/3), int((i+1)*length/3)):
            if camels[int(i*length/3)] != camels[j]:
                print("no")
                return(0)

    if camels[0] ^ camels[int(num/3)] != camels[int(num/3)*2]:
        print("no")
        return(0)

    print("yes")

solve()

Submission status: Wrong Answer

Solution code:
def main(N):
	a = list(map(int, input().split()))
	if N != 3:
		print("No")
		return
	a.sort()
	if (a[0]^a[2] == a[1]) and (a[0] == a[1]^a[2]) and(a[2]==a[0]^a[1]):
		print("Yes")
	else: print("No")
	return
		
	return

main(int(input()))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc035/tasks/agc035_a
import numpy as np


def calc(N: int, values: np.ndarray) -> bool:
    if N % 3 != 0:
        return False

    uniques = np.unique(values)
    if len(uniques) != 3:
        return False

    counts = [np.sum(values == v) for v in uniques]  # 各固有値の格納数
    if len(np.unique(counts)) != 1:
        return False

    sorted_uniques = np.sort(uniques)
    return sorted_uniques[0] == np.bitwise_xor(sorted_uniques[1], sorted_uniques[2])


def load_input_as_int_array():
    return np.array([int(v) for v in input().split(" ")])


N = int(input())
values = load_input_as_int_array()
result = calc(N, values)

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

Submission status: Wrong Answer

Solution code:
import itertools

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

for s in list(itertools.permutations(l)):
    if sum([s[(i-1)%n]^s[(i+1)%n]==s[i] for i in range(n)])==n:
        print('Yes')
        exit()
    else:pass
print('NO')

Submission status: Wrong Answer

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

def hat(_):
    for n in range(N):
        if a[n-2] ^ a[n] != a[n-1]:
            return False
        else:
            n += 2
    return True
            
ans = True
for n in range(N):
    ans = hat(n)
    if ans == False:
        break

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

Submission status: Wrong Answer

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

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

else:
    if len(set(a)) != 3 or a.count(list(set(a))[0]) != int(n/3) or a.count(list(set(a))[1]) != int(n/3) or a.count(list(set(a))[2]) != int(n/3):
        print("No")

    else:
        set_a = list(set(a))
        if set_a[0] == set_a[1]^set_a[2] and set_a[1] == set_a[2]^set_a[0] and set_a[2] == set_a[1]^set_a[0]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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


for i in range(0,n-2):
    if  (bin(a[i] ^ a[i+2]))==bin(a[i+1]):
        continue
    else:
        s=1

if  (bin(a[n-1] ^ a[1]))==bin(a[0]):
    f=0
else:
    s=1

if  bin((a[n-2] ^ a[0]))==bin(a[n-1]):
    f=0
else:
    s=1

if s==1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
num_hat = int(input())

numbers = [int(i) for i in input().split(' ')]
numbers.append(numbers[0])
numbers.append(numbers[1])

for i in range(1, num_hat+1):
    if numbers[i] != numbers[i-1] ^ numbers[i+1]:
        print("No")
        exit(0)

else:
    print("Yes")

exit(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
ans = "No"
Co = Counter(A)
if n%3 != 0:
    if len(Co.keys()) == 1:
        ans = "Yes"
else:
    tr = n//3
    Va = Co.values()
    if len(Va) == 3 and Co.most_common()[0][1] == Co.most_common()[1][1] == Co.most_common()[2][1]:
        ans = "Yes"
    elif len(Va) == 2 and Co.most_common()[0][0] == 2*tr:
        ans = "Yes"
    elif len(Va) == 1:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(N):
    if i == 0:
        a = bin(a_list[N-1])
        b = bin(a_list[i+1])
    elif i == N-1:
        a = bin(a_list[i-1])
        b = bin(a_list[0])
    else:
        a = bin(a_list[i-1])
        b = bin(a_list[i+1])
    c = int(a, 0) ^ int(b, 0)
    if c != a_list[i]:
        print("No")
        sys.exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
    
n=I()
a=LI()

a.sort()

def check(n,a):
    if n%3!=0:
        return False
    else:
        m=n//3
        c=a[0]
        for i in range(m):
            if a[i]!=c:
                k=0
                return False
        c=a[m]    
        for i in range(m):
            if a[m+i]!=c:
                k=0
                return False
                
        c=a[2*m]    
        for i in range(m):
            if a[2*m+i]!=c:
                k=0
                return False
        if a[0]^a[m]==a[m*2]:
            return True
            
if check(n,a):
    k=0
else:
    k=1
ans=['Yes','No']

print(['Yes','No'][k])