Submission #2708818
Source Code Expand
import strutils import sequtils import algorithm import math import queues import tables import sets import logging import future const INF* = int(1e18 + 373) proc readSeq*(): seq[string] = stdin.readLine().strip().split() proc readSeq*(n: Natural): seq[string] = result = newSeq[string](n) for i in 0..<n: result[i] = stdin.readLine().strip() proc readInt1*(): int = readSeq().map(parseInt)[0] proc readInt2*(): (int, int) = let a = readSeq().map(parseInt) return (a[0], a[1]) proc readInt3*(): (int, int, int) = let a = readSeq().map(parseInt) return (a[0], a[1], a[2]) proc readInt4*(): (int, int, int, int) = let a = readSeq().map(parseInt) return (a[0], a[1], a[2], a[3]) type seq2*[T] = seq[seq[T]] proc newSeq2*[T](n1, n2: Natural): seq2[T] = newSeqWith(n1, newSeq[T](n2)) #------------------------------------------------------------------------------# proc countTrailingZeros(x: int): int = if x == 0: return -1 var mask = 1 var count = 0 while (mask and x) == 0: mask = mask shl 1 count += 1 return count proc solve(n: int; a: seq[int]): int = var op = newSeq[bool](32) for i in 0..<n: op[countTrailingZeros(a[i])] = true var sum = 0 for i in 0..<n: sum = sum xor a[i] var ans = 0 for i in countdown(31, 0): if (sum and (1 shl i)) == 0: continue if not op[i]: return -1 sum = sum xor ((1 shl (i + 1)) - 1) ans += 1 return ans proc main() = let n = readInt1() let a = readSeq(n).map(parseInt) echo solve(n, a) main()
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | somq14 |
Language | Nim (0.13.0) |
Score | 500 |
Code Size | 1610 Byte |
Status | AC |
Exec Time | 23 ms |
Memory | 6652 KB |
Compile Error
Hint: system [Processing] Hint: Main [Processing] Hint: strutils [Processing] Hint: parseutils [Processing] Hint: sequtils [Processing] Hint: algorithm [Processing] Hint: math [Processing] Hint: times [Processing] Hint: queues [Processing] Hint: tables [Processing] Hint: hashes [Processing] Hint: etcpriv [Processing] Hint: sets [Processing] Hint: os [Processing] Hint: posix [Processing] Hint: logging [Processing] lib/pure/logging.nim(128, 22) Hint: 'Exception' is declared but not used [XDeclaredButNotUsed] Hint: future [Processing] Hint: macros [Processing] Hint: [Link] Hint: operation successful (24859 lines compiled; 2.757 sec total; 24.250MB; Release Build) [SuccessX]
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
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 | 1 ms | 256 KB |
001.txt | AC | 1 ms | 256 KB |
002.txt | AC | 21 ms | 6652 KB |
003.txt | AC | 11 ms | 3708 KB |
004.txt | AC | 10 ms | 2940 KB |
005.txt | AC | 7 ms | 2172 KB |
006.txt | AC | 22 ms | 6652 KB |
007.txt | AC | 22 ms | 6652 KB |
008.txt | AC | 22 ms | 6652 KB |
009.txt | AC | 22 ms | 6652 KB |
010.txt | AC | 22 ms | 6652 KB |
011.txt | AC | 22 ms | 6652 KB |
012.txt | AC | 22 ms | 6652 KB |
013.txt | AC | 22 ms | 6652 KB |
014.txt | AC | 22 ms | 6652 KB |
015.txt | AC | 22 ms | 6652 KB |
016.txt | AC | 22 ms | 6652 KB |
017.txt | AC | 22 ms | 6652 KB |
018.txt | AC | 22 ms | 6652 KB |
019.txt | AC | 23 ms | 6652 KB |
020.txt | AC | 22 ms | 6652 KB |
021.txt | AC | 3 ms | 892 KB |
022.txt | AC | 3 ms | 892 KB |
023.txt | AC | 22 ms | 6652 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |