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 = [int(s) for s in input().split(" ")]
dic_a = {}
for aa in a:
  if aa in dic_a:
    dic_a[aa] += 1
  else:
    dic_a[aa] = 0
a_set = list(dic_a.keys())
n_set = len(a_set)

if (n < 3):
  ans = False
elif 0 in a_set:
  ans = False
  for v in dic_a.values():
    if v >= 2:
      ans = True
      break
else:
  ans = False
  if 0 in a_set:
    for v in dic_a.values():
      if v >= 2:
        ans = True
        break
  if not ans:
    for i in range(n_set):
      for j in range(i + 1, n_set):
        aij = a_set[i] ^ a_set[j]
        if aij in a_set:
          ans = True
          break
      if ans:
        break

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
aa=set(a)
if len(aa)==2:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
first = A[-1]
dic = {}
dp = {}
for a in A[:-1]:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
import sys
sys.setrecursionlimit(10**5)
def DP(count,pre,num,f,s,dic):
    temp = pre ^ num

    if count == N - 3:
        if dic[temp] == s:
            return True
        else:
            return False
    if temp in dic:
        if dic[temp] >= 1:
            dic[temp] -= 1
            dp[(pre,num)] = DP(count + 1,num,dic[temp],f,s,dic)
            return dp[(pre,num)]
def main():
    flag = False
    for a in A[:-1]:
        if first ^ a in dic:
            if dic[first ^ a] >= 2:
                tdic = dic.copy()
                flag = DP(0,a,a ^ first,first,a,tdic) or flag
                if flag:
                    print('Yes')
                    return
    print('No')
    return
if N == 3:
    if A[0] ^ A[1] == A[2]:
        print('Yes')
    else:
        print('No')
else:
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
a= list(map(int, input().split()))
b=[None]*N
b[0]=a[0]
A=0
for i in range(1,N-1):
  c=a
  c[0]=0
  b[1]=a[i]
  c[i]=0
  for j in range(2,N):
    b[j]=b[j-1]^b[j-2]
    for k in range(1,N):
      if b[j]==c[k]:
        c[k]=0
        break
    else:
      break
    A=1
if A==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:
    for i in range(len(b)-1):
        if len(b)%3!=0:
            out=1
            print('No')
            break
        elif b[i]!=b[i+1]:
            print('No')
            out=1
            break
        else:
            pass
    if out==0:
        print('Yes')
else:
    if len(b)>2:
        print('No')
    elif len(b)==1:
        print('Yes')
    else:
        if a.count(0)*3==len(a):
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
figure = list(map(int, input().split()))
figure1 = []
p=0
for j in range(1,n):
  figure1.append(figure[0]^figure[j])
for k in range(n-1):
  if figure1[1]==figure[k]:
    print("Yes")
    p+=1
    break
if p==0:
  print("No")

Submission status: Wrong Answer

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

n = N - 1
x = a_int[0]
y = a_int[1]
z = a_int[2]
while bin(x ^ z) == bin(y):
	if z < a_int[n]:
		x = a_int[0 + 1]
		y = a_int[1 + 1]
		z = a_int[2 + 1]
	else:
		print("Yes")
		break
if z == a_int[n]:
	pass
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import itertools

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

while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
        elif c[0] ^ c[2] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
        else:
            print("No")
            exit()

Submission status: Wrong Answer

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

ok=False
a0=aa[0]
c_i=1
for i in aa[1:]:
    a = aa.copy()
    used = [False]*N

    tmp=a[0]
    used[0] = True
    a[0]=-1

    tmp2=i
    used[c_i]=True
    used[c_i]=-1

    for j in range(N-1):
        tmp3=tmp^tmp2
        if j==N-2 and tmp3==a0:
            ok=True
            break
        if not (tmp3 in a):
            break
        tmp3_idx = 0
        if used[tmp3_idx]==True:
            break
        else:
            used[tmp3_idx]=True
            a[tmp3_idx]=-1
            tmp=tmp2
            tmp2=tmp3
    c_i=c_i+1
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# A - XOR Circle
import itertools
import sys

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

# pattern = list(itertools.permutations(seq))
# for i in range(0, N):
#     for j in range(0, len(pattern[i])):
#         if (pattern[i][j-2] ^ pattern[i][j]) != pattern[i][j-1]:
#             print('No')
#             sys.exit(0)

for j in range(N):
    if (seq[j-2] ^ seq[j]) != seq[j-1]:
        print('No')
        sys.exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
P=int(input())
A=[int(i) for i in input().split(" ")]
ans=0

if len(set(A))==3:
	if P%3==0:
		if A.count(A[0])==P/3:
			n=A[0]
			A.remove(A[0])
			m=A[0]
			A.remove(A[0])
			l=A[0]
			if A.count(A[0])==P/3:
				if l==n|m:ans=1
if len(set(A))==1:
	if A[0]==0:ans=1
if len(set(A))==2:
	if P%2==1:
		if A.count(0)==P//2:ans=1


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

Submission status: Wrong Answer

Solution code:
import sys

def main():
    n = int(input())-1
    nums = list(map(int,input().split()))
    bins = []
    for num in nums:
        bins.append(int(bin(num)[2:]))

    #print(bins)
    #[1(0), 10(1), 11(2)]
    if int(str(sum(bins)).replace("2","0")) == 0:
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
import collections
c=dict(collections.Counter(l))
d=list(c.values())
e=list(c.keys())
if len(d)==3:
    d.sort()
    e.sort()
    if d[0]==d[1]==d[2] and e[0]^e[2]==e[1]:
        print("Yes")
    else:
        print("No")
elif len(d)==2:
    d.sort()
    e.sort()
    if d[0]==d[1] and e[0]==0:
        print("Yes")
    elif d[0]*2==d[1] and e[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()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:
    for i in range(len(b)-1):
        if len(b)%3!=0:
            print('No')
            break
        elif b[i]!=b[i+1]:
            print('No')
            out=1
            break
        else:
            pass
    if out==0:
        print('Yes')
else:
    if len(b)>2:
        print('No')
    elif len(b)==1:
        print('Yes')
    else:
        if a.count(0)*3==len(a):
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def equal_list(lst1, lst2):
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            break
    else:
        if not lst:
            return True
    return False


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

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

if N % 3 == 0:
    n = N // 3
    sets = list(set(a))
    order = max(a).bit_length()
    if len(sets) == 3:
        for s in sets:
            if a.count(s) != n:
                print("No")
                exit()

        for i in range(order):
            b = [sets[0] >> i & 1, sets[1] >> i & 1, sets[2] >> i & 1]
            if b == [0, 0, 0]:
                continue
            if not equal_list(b, [0, 1, 1]):
                print("No")
                exit()
    elif len(sets) == 2:
        if a.count(sets[0]) == n:
            for i in range(order):
                b = [sets[0] >> i & 1, sets[1] >> i & 1]
                if b == [0, 0]:
                    continue
                if b != [0, 1]:
                    print("No")
                    exit()
        elif a.count(sets[1]) == n:
            for i in range(order):
                b = [sets[0] >> i & 1, sets[1] >> i & 1]
                if b == [0, 0]:
                    continue
                if b != [1, 0]:
                    print("No")
                    exit()
    else:
        print("No")
        exit()

    print("Yes")

else:
    print("No")
    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
d = [0,0,0]
index = 0
if len(b) != 3:
    print("No")
    exit()
for i in list(b):
    for j in a:
        if i == j:
            d[index] += 1
    index += 1
if d[0] == d[1] and d[1] == d[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
A=list(set(a))
print("Yes" if len(A)==3 else "No")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int, input().split()))
b=sorted(a)
result = True
for idx in range(len(b)-1):
    prev = b[idx-1]
    next = b[idx+1]
    diff = next - prev
    if idx == 0:
        diff = -diff
    if diff != b[idx]:
        result = False
        break
if b[0]^b[len(b)-2] != b[len(b)-1]:
    result = False
str = "Yes" if result == True else "No"
print(str)

Submission status: Wrong Answer

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

ans = 0
if n == 3:
    if a[0]^a[1] == a[2]:
        ans = 1
    else:
        ans = 0
elif n == 4:
    if a[0]==0 and a[1]==0 and a[2]==0 and a[3]==0:
        ans = 1
    else:
        ans = 0
else:
    tmp = []
    cnt = []
    for i in range(n):
        if i == 0:
            tmp.append(a[i])
            cnt.append(1)
        else:
            if a[i-1] == a[i]:
                cnt[-1] += 1
            else:
                tmp.append(a[i])
                cnt.append(1)
    if n % 3 != 0:
        if tmp[0] == 0 and cnt[0] == n:
            ans = 1
    else:
        if len(tmp) == 3:
            if cnt[0] == cnt[1] and cnt[1] == cnt[2] and cnt[0]^cnt[1] == cnt[2]:
                ans = 1
        if len(tmp) == 2:
            if tmp[0] == 0:
                if cnt[0]*2 == cnt[1]:
                    ans = 1
        if len(tmp) == 1:
            if tmp[0] == 0:
                ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if 0 in a:
    print("Yes")
    exit()

if (a[0] ^ a[N-1]) in a:
    print("Yes")
    exit()

for i in range(N):
    j = i + 1
    while j < N - 1:
        if (a[j] ^ a[j+1]) in a:
            print("Yes")
            exit()
        j += 1

print("No")

Submission status: Wrong Answer

Solution code:
import collections

N = input()
N = int(N)
a = [ int(i) for i in input().split()]
c = collections.Counter(a)
hoge = False

def check(i,j):
    c[j] -= 1
    for k in range(len(a)-1):
        if c[i^j] == 0:
            return False
        c[i^j]-=1
        i2 = j
        j = i^j
        i = i2
    return True


if check(a[0],a[1]):
    hoge = True

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

Submission status: Wrong Answer

Solution code:
# 1.Nが三の倍数でない場合、全てが0でなければならない.(a_i=Σa_k∧a_(i-1)+a_(i+1)=a_iとなるのはa_i=0のみ)
# 2.Nが3の倍数の場合、a,b,a+bを満たす三種類以下の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
string = "No"
if(N%3 == 0):
    input_dict = {}
    for i in map(int, input().split()):
        if(i in input_dict):
            input_dict[i] += 1
        else:
            input_dict[i] = 1
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[2] == input_list[1]):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    string = "Yes"
    for i in map(int, input().split()):
        if(i != 0):
            string = "No"
            break
print(string)

Submission status: Wrong Answer

Solution code:
N = int(input())
Rakuda_data =  input().split(' ')
flag = 0

for n in range(0, N):
    if 0 == int(n):
        Flontstr = int(Rakuda_data[N-1])
        binstr = int(Rakuda_data[0])
        Afterstr = int(Rakuda_data[1])
    elif 0 < int(n) and int(n) < N-1:
        Flontstr = int(Rakuda_data[n-2])
        binstr = int(Rakuda_data[n-1])
        Afterstr = int(Rakuda_data[n])
    elif N-1==int(n):
        Flontstr = int(Rakuda_data[N-2])
        binstr = int(Rakuda_data[N-1])
        Afterstr = int(Rakuda_data[0])
        
        
    # XOR回路
    if bin(Flontstr ^ Afterstr) != bin(binstr):
        flag=1
        print('No')
        break
    
    if int(n)==N-1 and flag==0:
        print('Yes')

Submission status: Wrong Answer

Solution code:

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

ans = []

f = True

for i in range(N):
    if f:
        if i == 0:
            a1 = a[0]
            a2 = a[1]
            if a1^a2 in a:
                ans.append(a1)
                a.remove(a1)
                ans.append(a2)
                a.remove(a2)
            else:
                f = False
                continue
        elif i == N-1:
            a1 = ans[i-1]
            a2 = ans[i]
            if a1^a2 == ans[0]:
                print("Yes")
            else:
                print("No")
                break
        else:
            a1 = ans[i-1]
            a2 = ans[i]
            if a1^a2 in a:
                ans.append(a1^a2)
                a.remove(a1^a2)
            else:
                f = False
                continue
    else:
        print("No")
        break

Submission status: Wrong Answer

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

flag = 0
for i in range(n):
    l = i + 1
    r = i - 1
    if(l >= n): l = 0
    if(r < 0): r = n - 1
    
    if(a[i] != int(bin(a[r] ^ a[l]) ,2)):
        flag = 1
        break
        
if(flag == 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

def all_zero(a):
    for e in a:
        if e != 0:
            return False
    return True

def three_mod_same(a):
    counts = {}
    for e in a:
        if e not in counts:
            counts[e] = 1
        else:
            counts[e] += 1

    for v in counts.values():
        if v != len(a) // 3:
            return False
    return True

if len(set(a)) != 3:
    if all_zero(a):
        print("Yes")
    else:
        print("No")
else:
    p = itertools.permutations(list(set(a)), 3)
    yes = False
    for permed_a in p:            
        good_perm = True
        for i in range(3):
            if permed_a[(i + 1) % 3] != (permed_a[i] ^ permed_a[(i + 2) % 3]):
                good_perm = False
                break
        if good_perm:
            yes = True
            break
    if not yes:
        print("No")
    else:
        if three_mod_same(a):
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
    if bin(a[N-1] ^ a[1]) == bin(a[0]):
        for i in range(0,N-2):
            if Flag==True:
                if bin(a[i] ^ a[i+2]) == bin(a[i+1]):
                  pass
                else:        
                  Flag=False                  
        if Flag==True:
            print("Yes")
        else:
            print("No")
    else:
        print("No")    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==1 and a[0]==0:
  print('Yes')
elif len(set(a))!=3:
  print('No')
else:
  a=list(set(a))
  for i in range(len(a)):
    a[i]=format(a[i],'020b')
  l=[0 for i in range(20)]
  for i in range(len(a)):
    for j in range(20):
      if a[i][j]=='1':
        l[j]+=1
  ct=0
  for j in range(20):
    if l[j]==2 or l[j]==0:ct+=1
  if ct==20:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

for i in range(len(nums)):
  if i == 0:
    counts += nums[0] is (nums[-1] ^ nums[1])
  elif i == len(nums) - 1:
    counts += nums[-1] is (nums[-2] ^ nums[0])
  else:
    counts += nums[i] is (nums[i - 1] ^ nums[i + 1])
  
if counts == len(nums):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    array = list(map(int, input().split()))
    set_array = list(set(array))
    if N != len(array):
        return "No"
    if N < 3:
        return "No"
    if len(set_array) == 1 and set_array[0] == 0:
        return "Yes"
    if len(set_array) == 3:
        for i in range(2):
            if array.count(set_array[i]) != array.count(set_array[i+1]):
                return "No"
        x = set_array[0]
        y = set_array[1]
        z = set_array[2]
        if x ^ y == z and y ^ z == x and x ^ z == y:
            return "Yes" 
    if len(set_array) == 2:
        x = min(set_array)
        y = max(set_array)
        if array.count(x)*2 != array.count(y):
            if x == 0 and y^y == 0 and x^y == y:
                return "Yes"
    return "No"

print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(s) for s in input().split(" ")]
dic_a = {}
for aa in a:
  if aa in dic_a:
    dic_a[aa] += 1
  else:
    dic_a[aa] = 0
a_set = list(dic_a.keys())
n_set = len(a_set)

if (n < 3):
  ans = False
elif 0 in a_set:
  ans = False
  for v in dic_a.values():
    if v >= 2:
      ans = True
      break
else:
  ans = False
  for i in range(n_set):
    for j in range(i + 1, n_set):
      aij = a_set[i] ^ a_set[j]
      if aij in a_set:
        ans = True
        break
    if ans:
      break

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

Submission status: Wrong Answer

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

if n%3==0 and 0 in line and line.count(0)==n//3 and len(s)<=2:
    print('Yes')
elif  n%3==0 and len(s)==3 and s[0]^s[1]==s[2] and s[1]^s[2]==s[0] and line.count(s[0])==n//3 and line.count(s[1])==n//3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

n = N - 1
x = a_int[0]
y = a_int[1]
z = a_int[2]
while bin(x ^ z) == bin(y):
	if z < a_int[n]:
		x = a_int[0 + 1]
		y = a_int[1 + 1]
		z = a_int[2 + 1]
	else:
		print("yes")
		break
if z == a_int[n]:
	pass
else:
	print("no")

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
flag = True
syugo = set(sorted(data))
if len(syugo) == 2:
    syugo = list(syugo)
    if syugo[0] != 0:
        flag = False
    if data.count(syugo[1]) // data.count(0) != 2:
        flag = False
        
elif len(set(data)) == 3:
    syugo = list(syugo)
    if syugo[0]^syugo[1] != syugo[2]:
        flag = False
    if len(set([data.count(i) for i in syugo])) != 1:
        flag = False
else:
    flag = False

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

Submission status: Wrong Answer

Solution code:
P=int(input())
A=[int(i) for i in input().split(" ")]
ans=0

if len(set(A))==3:
	if P%3==0:
		if A.count(A[0])==P/3:
			n=A[0]
			A.remove(A[0])
			m=A[0]
			A.remove(A[0])
			l=A[0]
			if A.count(A[0])==P/3:
				if l==n|m:ans=1
if len(set(A))==1:
	if A[0]==0:ans=1
if len(set(A))==2:
	if A.count(0)==P//2:ans=1


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

Submission status: Wrong Answer

Solution code:
n = input()
n = int(n)
a = input().split()
a = [abs(int(i)) for i in a]
a.append(a[0])
a.append(a[1])
c = 1
for i in range(n):
  if a[c-1] ^ a[c+1] == a[c]:
    c += 1
  else: 
    print('No')
    break
if c == n+1:
  print('Yes')

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==1 and a[0]==0:
  print('Yes')
elif n%3!=0:
  print('No')
elif len(set(a))!=3:
  print('No')
else:
  a=list(set(a))
  for i in range(len(a)):
    a[i]=format(a[i],'020b')
  l=[0 for i in range(20)]
  for i in range(len(a)):
    for j in range(20):
      if a[i][j]=='1':
        l[j]+=1
  ct=0
  for j in range(20):
    if l[j]==2 or l[j]==0:ct+=1
  if ct==20:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

dic = defaultdict(int)

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

n = len(dic.keys())
cnts = dic.values()

if n == 3 and min(cnts) == max(cnts):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import collections
 
n = int(input())
a_list = list(map(int,input().split()))
 
c = collections.Counter(a_list)
 
#print(len(c.keys()))
ans_list = list(c.keys())
count_list = list(c.values())
count_list.sort()
 
#print(c.keys())
if len(c.keys()) == 1:
    if list(c.keys()) == [0]:
        print("Yes")
        quit()
 
if len(c.keys()) != 3:
    print("No")
    quit()
 
if ans_list[0] == ans_list[1] ^ ans_list[2]:
    if count_list[0]==count_list[1]==count_list[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

A.sort()

res = True
for i in range(len(A)):
    j = (i+1) % len(A)
    k = (i+2) % len(A)
    a0 = A[i]
    a1 = A[j]
    a2 = A[k]
    if a1 != a0 ^ a2:
        res = False

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
for i in c.values():
    b.append(i)
if a.count(0)==0:
    for i in range(len(b)-1):
        if len(b)%3!=0:
            print('No')
            break
        elif b[i]!=b[i+1]:
            print('No')
            break
        elif i==len(b)-2:
            print('Yes')
            break
        else:
            pass
else:
    if len(b)>2:
        print('No')
    elif len(b)==1:
        print('Yes')
    else:
        if a.count(0)*3==len(a):
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int, input().split()))
l = num[0]
r = num[1]
num.remove(r)
sum_ = l ^ r
i = 1
 
while i < n:
  try:
    num.remove(sum_)  
  except:
    print("No")
    exit()
  else:
    l, r = r, sum_
    sum_ = l ^ r
    i += 1
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
Rakuda_data =  input().split(' ')
flag = 0

print(Rakuda_data)

for n in range(0, N):
    print(n)
    if 0 == int(n):
        Flontstr = int(Rakuda_data[N-1])
        binstr = int(Rakuda_data[0])
        Afterstr = int(Rakuda_data[1])
    elif 0 < int(n) and int(n) < N-1:
        Flontstr = int(Rakuda_data[n-2])
        binstr = int(Rakuda_data[n-1])
        Afterstr = int(Rakuda_data[n])
    elif N-1==int(n):
        Flontstr = int(Rakuda_data[N-2])
        binstr = int(Rakuda_data[N-1])
        Afterstr = int(Rakuda_data[0])
        
        
    # XOR回路
    if bin(Flontstr ^ Afterstr) != bin(binstr):
        flag=1
        print('No')
        break
    
    if int(n)==N-1 and flag==0:
        print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
aa=set(a)
if len(aa)==1:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
first = A[-1]
dic = {}
dp = {}
for a in A[:-1]:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
import sys
sys.setrecursionlimit(10**5)
def DP(count,pre,num,f,s,dic):
    temp = pre ^ num
    if count == N - 3:
        if dic[temp] == s:
            return True
        else:
            return False
    if (pre,num) in dp:
        return dp        
    if temp in dic:
        if dic[temp] >= 1:
            dic[temp] -= 1
            dp[(pre,num)] = DP(count + 1,num,dic[temp],f,s,dic)
            return dp[(pre,num)]
def main():
    flag = False
    for a in A[:-1]:
        if first ^ a in dic:
            if dic[first ^ a] >= 2:
                tdic = dic.copy()
                flag = DP(0,a,a ^ first,first,a,tdic) or flag
                if flag:
                    print('Yes')
                    return
    print('No')
    return
if N == 3:
    if A[0] ^ A[1] == A[2]:
        print('Yes')
    else:
        print('No')
else:
    main()

Submission status: Wrong Answer

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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
                if aa in a:
                    count += 1
                if count != 2:
                    flag = 1
                    break
            else:
                continue
            break

else:
    if len(odd)/2 != len(even):
        flag = 1
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
                if aa in a:
                    count += 1
                if count != 2:
                    flag = 1
                    break
            else:
                continue
            break

if flag == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=list(map(int, input().split()))
frag=False
#O(N^2) MAX(N): 10^5: WORST==10_000_000_000

l=np.array([],dtype=np.uint32)
xor=np.array([],dtype=np.uint32)
for j in range(n):
    l=np.append(l,a[j%n])
    if j > 0:
        xor=np.append(xor,np.bitwise_xor(l[j],l[j-1]))
        if j == n-1: 
            xor=np.append(xor,np.bitwise_xor(l[0],l[-1]))
xor = np.roll(xor, -1)
if np.all(l==xor): 
    frag=True
#print(l,xor)
print("Yes" if frag else "No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	#S = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	A = input().split()
	A = [int(s) for s in A]
	A.sort()

	print("Yes")
	sys.exit()

	a_max = A[-1]
	#A[-1] = -1

	a = 2
	i = 1
	ll = [1]
	while a < 100000+1:
		a = 2 ** i
		ll.append(a)
		i += 1
		if a_max == a:
			print("No")
			sys.exit()

	tmp = 0
	flg = False
	for i in ll:
		tmp += i
		if a_max == tmp:
			flg = True
			break
	
	if flg == False:
			print("No")
			sys.exit()

	bk = -1
	next1 = -1
	for i, val in enumerate(A):
		#A[i] = -1
		if i == 0:
			tmp = a_max - val
			if tmp in A:
				bk = val
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
		if i == N-1:
			if next1 == a_max and bk ^ A[0] == a_max:
				print("Yes")
				sys.exit()
		
		if next1 == a_max:
			tmp = next1 - bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()

		elif next1 == A[0]:
			tmp = a_max - next1
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				#print(next1)
				print("No")
				sys.exit()

		else:
			tmp = next1 + bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
	print("No")


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
P=int(input())
A=[int(i) for i in input().split(" ")]
ans=0

if len(set(A))==3:
	if P%3==0:
		if A.count(A[0])==P/3:
			n=A[0]
			A.remove(A[0])
			m=A[0]
			A.remove(A[0])
			l=A[0]
			if A.count(A[0])==P/3:
				if l==n|m:ans=1
if len(set(A))==1:
	if A[0]==0:ans=1
if len(set(A))==2:
	if A.count(0)==P//2:ans=1


if ans==1:
	print("yes")
else:
	print("No")