Submission #3415129
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 access(firstIndexOf: Table[int, int]; i: int): int = if i in firstIndexOf: firstIndexOf[i] else: INF proc main() = let s = stdin.readLine().map(it => it.ord() - 'a'.ord()) let n = s.len() var cum = newSeq[int](n + 1) for i in 0..<n: cum[i + 1] = cum[i] xor (1 shl s[i]) let alphabet = 'z'.ord() - 'a'.ord() + 1 var firstIndexOf = initTable[int, int]() for i in 0..n: if cum[i] notin firstIndexOf: firstIndexOf[cum[i]] = INF firstIndexOf[cum[i]] = min(firstIndexOf[cum[i]], i) var dp = newSeq[int](n + 1) dp[0] = 0 for i in 1..n: var opt = dp[i - 1] + 1 let j = firstIndexOf.access(cum[i]) if j < i: opt = min(opt, dp[j] + 1) for c in 0..<alphabet: let j = firstIndexOf.access(cum[i] xor (1 shl c)) if j < i: opt = min(opt, dp[j] + 1) dp[i] = opt echo dp[n] main()
Submission Info
Submission Time | |
---|---|
Task | D - Yet Another Palindrome Partitioning |
User | somq14 |
Language | Nim (0.13.0) |
Score | 0 |
Code Size | 1824 Byte |
Status | WA |
Exec Time | 3156 ms |
Memory | 23660 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 (24858 lines compiled; 2.570 sec total; 25.256MB; Release Build) [SuccessX]
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt, 1_64.txt, 1_65.txt, 1_66.txt, 1_67.txt, 1_68.txt, 1_69.txt, 1_70.txt, 1_71.txt, 1_72.txt, 1_73.txt, 1_74.txt, 1_75.txt, 1_76.txt, 1_77.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | TLE | 3155 ms | 8288 KB |
1_09.txt | AC | 364 ms | 5500 KB |
1_10.txt | AC | 328 ms | 5500 KB |
1_11.txt | AC | 464 ms | 5500 KB |
1_12.txt | AC | 32 ms | 5372 KB |
1_13.txt | AC | 42 ms | 5500 KB |
1_14.txt | AC | 41 ms | 5500 KB |
1_15.txt | AC | 138 ms | 5500 KB |
1_16.txt | AC | 242 ms | 5500 KB |
1_17.txt | AC | 210 ms | 5500 KB |
1_18.txt | AC | 609 ms | 5500 KB |
1_19.txt | AC | 1202 ms | 5500 KB |
1_20.txt | AC | 1555 ms | 5500 KB |
1_21.txt | AC | 2731 ms | 5500 KB |
1_22.txt | TLE | 3155 ms | 5500 KB |
1_23.txt | TLE | 3155 ms | 7676 KB |
1_24.txt | TLE | 3155 ms | 4476 KB |
1_25.txt | TLE | 3155 ms | 6140 KB |
1_26.txt | TLE | 3155 ms | 5132 KB |
1_27.txt | TLE | 3156 ms | 9836 KB |
1_28.txt | TLE | 3155 ms | 8300 KB |
1_29.txt | TLE | 3155 ms | 8296 KB |
1_30.txt | WA | 417 ms | 14452 KB |
1_31.txt | TLE | 3155 ms | 5124 KB |
1_32.txt | TLE | 3155 ms | 8292 KB |
1_33.txt | TLE | 3155 ms | 8288 KB |
1_34.txt | TLE | 3155 ms | 12804 KB |
1_35.txt | AC | 269 ms | 23656 KB |
1_36.txt | AC | 134 ms | 23572 KB |
1_37.txt | AC | 129 ms | 23660 KB |
1_38.txt | TLE | 3155 ms | 6760 KB |
1_39.txt | TLE | 3155 ms | 6756 KB |
1_40.txt | TLE | 3155 ms | 6756 KB |
1_41.txt | TLE | 3155 ms | 6760 KB |
1_42.txt | TLE | 3155 ms | 6760 KB |
1_43.txt | TLE | 3155 ms | 6756 KB |
1_44.txt | TLE | 3155 ms | 6764 KB |
1_45.txt | TLE | 3155 ms | 6756 KB |
1_46.txt | TLE | 3155 ms | 5220 KB |
1_47.txt | TLE | 3155 ms | 5232 KB |
1_48.txt | TLE | 3155 ms | 5224 KB |
1_49.txt | TLE | 3155 ms | 5224 KB |
1_50.txt | TLE | 3155 ms | 5224 KB |
1_51.txt | TLE | 3155 ms | 5216 KB |
1_52.txt | TLE | 3155 ms | 5228 KB |
1_53.txt | TLE | 3155 ms | 5220 KB |
1_54.txt | TLE | 3155 ms | 4476 KB |
1_55.txt | TLE | 3155 ms | 4476 KB |
1_56.txt | TLE | 3155 ms | 4476 KB |
1_57.txt | TLE | 3155 ms | 4476 KB |
1_58.txt | TLE | 3155 ms | 6496 KB |
1_59.txt | TLE | 3155 ms | 4476 KB |
1_60.txt | TLE | 3155 ms | 4476 KB |
1_61.txt | TLE | 3155 ms | 6496 KB |
1_62.txt | TLE | 3105 ms | 5628 KB |
1_63.txt | TLE | 3155 ms | 5628 KB |
1_64.txt | TLE | 3155 ms | 5628 KB |
1_65.txt | TLE | 3144 ms | 5628 KB |
1_66.txt | AC | 2214 ms | 5628 KB |
1_67.txt | AC | 2136 ms | 5628 KB |
1_68.txt | AC | 2284 ms | 5628 KB |
1_69.txt | AC | 2505 ms | 5628 KB |
1_70.txt | AC | 1990 ms | 5500 KB |
1_71.txt | TLE | 3155 ms | 5500 KB |
1_72.txt | AC | 1522 ms | 5628 KB |
1_73.txt | AC | 1921 ms | 5500 KB |
1_74.txt | AC | 1378 ms | 5500 KB |
1_75.txt | AC | 2208 ms | 5500 KB |
1_76.txt | AC | 1360 ms | 5500 KB |
1_77.txt | AC | 1290 ms | 5500 KB |