Submission #3415201
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[int32](1 shl alphabet) firstIndexOf.fill(1000000000) for i in 0..n: firstIndexOf[cum[i]] = min(firstIndexOf[cum[i]], i.int32()) 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 | 1680 Byte |
Status | WA |
Exec Time | 171 ms |
Memory | 266236 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 (24855 lines compiled; 2.574 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 | AC | 110 ms | 262396 KB |
0_01.txt | AC | 110 ms | 262396 KB |
0_02.txt | AC | 109 ms | 262396 KB |
0_03.txt | AC | 109 ms | 262396 KB |
1_00.txt | AC | 109 ms | 262396 KB |
1_01.txt | AC | 108 ms | 262396 KB |
1_02.txt | AC | 110 ms | 262396 KB |
1_03.txt | AC | 109 ms | 262396 KB |
1_04.txt | AC | 109 ms | 262396 KB |
1_05.txt | AC | 109 ms | 262396 KB |
1_06.txt | AC | 109 ms | 262396 KB |
1_07.txt | AC | 110 ms | 262396 KB |
1_08.txt | AC | 149 ms | 266108 KB |
1_09.txt | AC | 122 ms | 266108 KB |
1_10.txt | AC | 124 ms | 266108 KB |
1_11.txt | AC | 123 ms | 266236 KB |
1_12.txt | AC | 123 ms | 266008 KB |
1_13.txt | AC | 124 ms | 266108 KB |
1_14.txt | AC | 123 ms | 266108 KB |
1_15.txt | AC | 123 ms | 266108 KB |
1_16.txt | AC | 124 ms | 266108 KB |
1_17.txt | AC | 126 ms | 266108 KB |
1_18.txt | AC | 126 ms | 266108 KB |
1_19.txt | AC | 124 ms | 266108 KB |
1_20.txt | AC | 124 ms | 266108 KB |
1_21.txt | AC | 122 ms | 266108 KB |
1_22.txt | AC | 146 ms | 266108 KB |
1_23.txt | AC | 140 ms | 266108 KB |
1_24.txt | AC | 144 ms | 266108 KB |
1_25.txt | AC | 161 ms | 266108 KB |
1_26.txt | AC | 145 ms | 265996 KB |
1_27.txt | AC | 169 ms | 266108 KB |
1_28.txt | AC | 158 ms | 266108 KB |
1_29.txt | AC | 152 ms | 266108 KB |
1_30.txt | WA | 162 ms | 266108 KB |
1_31.txt | AC | 157 ms | 265988 KB |
1_32.txt | AC | 165 ms | 266108 KB |
1_33.txt | WA | 163 ms | 266108 KB |
1_34.txt | AC | 166 ms | 265992 KB |
1_35.txt | AC | 171 ms | 266108 KB |
1_36.txt | AC | 168 ms | 266012 KB |
1_37.txt | AC | 168 ms | 266108 KB |
1_38.txt | AC | 146 ms | 266108 KB |
1_39.txt | AC | 145 ms | 266108 KB |
1_40.txt | AC | 146 ms | 266108 KB |
1_41.txt | WA | 147 ms | 266108 KB |
1_42.txt | AC | 144 ms | 266108 KB |
1_43.txt | AC | 141 ms | 266108 KB |
1_44.txt | AC | 142 ms | 266108 KB |
1_45.txt | AC | 144 ms | 266108 KB |
1_46.txt | AC | 139 ms | 266108 KB |
1_47.txt | WA | 140 ms | 266224 KB |
1_48.txt | AC | 139 ms | 266108 KB |
1_49.txt | WA | 141 ms | 266108 KB |
1_50.txt | AC | 138 ms | 266108 KB |
1_51.txt | AC | 138 ms | 266108 KB |
1_52.txt | AC | 135 ms | 266108 KB |
1_53.txt | WA | 134 ms | 266108 KB |
1_54.txt | AC | 132 ms | 266108 KB |
1_55.txt | AC | 134 ms | 266108 KB |
1_56.txt | AC | 133 ms | 266108 KB |
1_57.txt | AC | 136 ms | 266108 KB |
1_58.txt | AC | 132 ms | 266108 KB |
1_59.txt | AC | 132 ms | 266108 KB |
1_60.txt | AC | 132 ms | 266108 KB |
1_61.txt | AC | 134 ms | 266108 KB |
1_62.txt | AC | 130 ms | 266108 KB |
1_63.txt | AC | 131 ms | 266108 KB |
1_64.txt | AC | 131 ms | 266108 KB |
1_65.txt | AC | 133 ms | 266108 KB |
1_66.txt | AC | 131 ms | 266108 KB |
1_67.txt | AC | 130 ms | 266236 KB |
1_68.txt | AC | 132 ms | 266108 KB |
1_69.txt | AC | 131 ms | 266108 KB |
1_70.txt | AC | 130 ms | 266108 KB |
1_71.txt | AC | 132 ms | 266108 KB |
1_72.txt | AC | 130 ms | 266108 KB |
1_73.txt | AC | 131 ms | 266108 KB |
1_74.txt | AC | 130 ms | 266108 KB |
1_75.txt | AC | 128 ms | 266108 KB |
1_76.txt | AC | 130 ms | 266108 KB |
1_77.txt | AC | 129 ms | 266108 KB |