Submission #3728948


Source Code Expand

import sys
N=int(input())
A=[int(input()) for i in range(N)]
A=sorted(A,reverse=True)
L=[0]*30
M=[0]*30
for a in A:
    s=bin(a)[2:]
    s=s[::-1]
    t=0
    for i in range(len(s)):
        if s[i]=='1':
            L[i]+=1
            if t==0:
                M[i]+=1
                t=1
ans=0
for i in range(29,-1,-1):
    if L[i]%2==1:
        if M[i]==0:
            print(-1)
            sys.exit()
        ans+=1
        if i!=0:
            for j in range(i):
                L[j]+=1
        #print(i,ans)
print(ans)

Submission Info

Submission Time
Task C - Cheating Nim
User okumura
Language PyPy3 (2.4.0)
Score 500
Code Size 551 Byte
Status AC
Exec Time 678 ms
Memory 53080 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 170 ms 38256 KB
001.txt AC 171 ms 38256 KB
002.txt AC 678 ms 53080 KB
003.txt AC 430 ms 48088 KB
004.txt AC 415 ms 46936 KB
005.txt AC 355 ms 45272 KB
006.txt AC 649 ms 51588 KB
007.txt AC 630 ms 51544 KB
008.txt AC 624 ms 51416 KB
009.txt AC 626 ms 51544 KB
010.txt AC 610 ms 51544 KB
011.txt AC 625 ms 51544 KB
012.txt AC 624 ms 51416 KB
013.txt AC 620 ms 51416 KB
014.txt AC 620 ms 51416 KB
015.txt AC 642 ms 51720 KB
016.txt AC 645 ms 51544 KB
017.txt AC 632 ms 51416 KB
018.txt AC 622 ms 51416 KB
019.txt AC 620 ms 51544 KB
020.txt AC 618 ms 51416 KB
021.txt AC 276 ms 43992 KB
022.txt AC 276 ms 43992 KB
023.txt AC 611 ms 52312 KB
example0.txt AC 175 ms 38256 KB
example1.txt AC 176 ms 38256 KB