Submission #5010987


Source Code Expand

# -*- coding: utf-8 -*-

import sys
from collections import Counter
from functools import reduce
from operator import xor

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=[INT() for i in range(N)]

mnbit=[0]*N
for i, a in enumerate(A):
    bina=format(a, 'b')
    mnbit[i]=len(bina)-bina.rfind('1')
C=Counter(mnbit)

res=reduce(xor, A, 0)
ln=len(format(res, 'b'))
cnt=0
for i in range(ln):
    idx=ln-i
    if res>>(idx-1)&1:
        if C[idx]:
            res^=(1<<idx)-1
            cnt+=1
        else:
            print(-1)
            exit()
print(cnt)

Submission Info

Submission Time
Task C - Cheating Nim
User Coki628
Language Python (3.4.3)
Score 500
Code Size 1076 Byte
Status AC
Exec Time 191 ms
Memory 8448 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 26
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 23 ms 3568 KB
001.txt AC 23 ms 3568 KB
002.txt AC 176 ms 8444 KB
003.txt AC 110 ms 5984 KB
004.txt AC 95 ms 5864 KB
005.txt AC 70 ms 5104 KB
006.txt AC 175 ms 8344 KB
007.txt AC 179 ms 8428 KB
008.txt AC 176 ms 8428 KB
009.txt AC 171 ms 8432 KB
010.txt AC 175 ms 8448 KB
011.txt AC 183 ms 8428 KB
012.txt AC 173 ms 8428 KB
013.txt AC 177 ms 8432 KB
014.txt AC 174 ms 8364 KB
015.txt AC 178 ms 8428 KB
016.txt AC 177 ms 8348 KB
017.txt AC 191 ms 8348 KB
018.txt AC 181 ms 8448 KB
019.txt AC 179 ms 8348 KB
020.txt AC 175 ms 8428 KB
021.txt AC 37 ms 3952 KB
022.txt AC 37 ms 3952 KB
023.txt AC 177 ms 8444 KB
example0.txt AC 23 ms 3568 KB
example1.txt AC 23 ms 3568 KB