Submission #3415026
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 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 = newSeq[int](1 shl alphabet) firstIndexOf.fill(INF) for i in 0..n: 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[cum[i]] if j < i: opt = min(opt, dp[j] + 1) for c in 0..<alphabet: let j = firstIndexOf[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 | 1661 Byte |
Status | MLE |
Exec Time | 257 ms |
Memory | 528356 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 (24854 lines compiled; 2.546 sec total; 24.250MB; 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 | MLE | 187 ms | 524540 KB |
0_01.txt | MLE | 187 ms | 524540 KB |
0_02.txt | MLE | 187 ms | 524540 KB |
0_03.txt | MLE | 187 ms | 524540 KB |
1_00.txt | MLE | 187 ms | 524540 KB |
1_01.txt | MLE | 187 ms | 524540 KB |
1_02.txt | MLE | 187 ms | 524540 KB |
1_03.txt | MLE | 187 ms | 524540 KB |
1_04.txt | MLE | 187 ms | 524540 KB |
1_05.txt | MLE | 187 ms | 524540 KB |
1_06.txt | MLE | 187 ms | 524540 KB |
1_07.txt | MLE | 187 ms | 524540 KB |
1_08.txt | MLE | 235 ms | 528252 KB |
1_09.txt | MLE | 199 ms | 528252 KB |
1_10.txt | MLE | 204 ms | 528252 KB |
1_11.txt | MLE | 202 ms | 528252 KB |
1_12.txt | MLE | 199 ms | 528152 KB |
1_13.txt | MLE | 198 ms | 528252 KB |
1_14.txt | MLE | 199 ms | 528252 KB |
1_15.txt | MLE | 202 ms | 528252 KB |
1_16.txt | MLE | 201 ms | 528252 KB |
1_17.txt | MLE | 204 ms | 528252 KB |
1_18.txt | MLE | 203 ms | 528252 KB |
1_19.txt | MLE | 206 ms | 528252 KB |
1_20.txt | MLE | 203 ms | 528252 KB |
1_21.txt | MLE | 204 ms | 528252 KB |
1_22.txt | MLE | 226 ms | 528252 KB |
1_23.txt | MLE | 224 ms | 528252 KB |
1_24.txt | MLE | 223 ms | 528252 KB |
1_25.txt | MLE | 240 ms | 528252 KB |
1_26.txt | MLE | 224 ms | 528140 KB |
1_27.txt | MLE | 254 ms | 528252 KB |
1_28.txt | MLE | 236 ms | 528252 KB |
1_29.txt | MLE | 237 ms | 528252 KB |
1_30.txt | MLE | 249 ms | 528252 KB |
1_31.txt | MLE | 240 ms | 528132 KB |
1_32.txt | MLE | 249 ms | 528356 KB |
1_33.txt | MLE | 246 ms | 528252 KB |
1_34.txt | MLE | 253 ms | 528136 KB |
1_35.txt | MLE | 254 ms | 528252 KB |
1_36.txt | MLE | 253 ms | 528156 KB |
1_37.txt | MLE | 257 ms | 528252 KB |
1_38.txt | MLE | 227 ms | 528252 KB |
1_39.txt | MLE | 228 ms | 528252 KB |
1_40.txt | MLE | 228 ms | 528252 KB |
1_41.txt | MLE | 229 ms | 528252 KB |
1_42.txt | MLE | 225 ms | 528252 KB |
1_43.txt | MLE | 224 ms | 528252 KB |
1_44.txt | MLE | 226 ms | 528252 KB |
1_45.txt | MLE | 226 ms | 528252 KB |
1_46.txt | MLE | 219 ms | 528252 KB |
1_47.txt | MLE | 221 ms | 528252 KB |
1_48.txt | MLE | 219 ms | 528252 KB |
1_49.txt | MLE | 219 ms | 528252 KB |
1_50.txt | MLE | 216 ms | 528252 KB |
1_51.txt | MLE | 220 ms | 528252 KB |
1_52.txt | MLE | 218 ms | 528252 KB |
1_53.txt | MLE | 218 ms | 528252 KB |
1_54.txt | MLE | 213 ms | 528252 KB |
1_55.txt | MLE | 216 ms | 528252 KB |
1_56.txt | MLE | 213 ms | 528252 KB |
1_57.txt | MLE | 214 ms | 528252 KB |
1_58.txt | MLE | 213 ms | 528252 KB |
1_59.txt | MLE | 214 ms | 528252 KB |
1_60.txt | MLE | 213 ms | 528252 KB |
1_61.txt | MLE | 213 ms | 528252 KB |
1_62.txt | MLE | 210 ms | 528252 KB |
1_63.txt | MLE | 212 ms | 528252 KB |
1_64.txt | MLE | 211 ms | 528252 KB |
1_65.txt | MLE | 214 ms | 528252 KB |
1_66.txt | MLE | 210 ms | 528252 KB |
1_67.txt | MLE | 209 ms | 528252 KB |
1_68.txt | MLE | 210 ms | 528252 KB |
1_69.txt | MLE | 210 ms | 528252 KB |
1_70.txt | MLE | 211 ms | 528252 KB |
1_71.txt | MLE | 209 ms | 528252 KB |
1_72.txt | MLE | 208 ms | 528252 KB |
1_73.txt | MLE | 210 ms | 528252 KB |
1_74.txt | MLE | 209 ms | 528252 KB |
1_75.txt | MLE | 207 ms | 528252 KB |
1_76.txt | MLE | 208 ms | 528252 KB |
1_77.txt | MLE | 211 ms | 528252 KB |