Submission #7130285


Source Code Expand

import sequtils, strutils

const
  btn = "ABXY"
let
  n = stdin.readline.parseInt
  cs = stdin.readline

proc cnt(s:string, sub:seq[string]): int =
  var dp = newSeq[int](len(s))
  dp[0] = 1
  if len(s) > 1 and s[0..1] in sub:
    dp[1] = 1
  elif len(s) > 1:
    dp[1] = 2
  for i in 2..<len(s):
    dp[i] = dp[i-1]+1
    if s[(i-1)..i] in sub:
      dp[i] = min(dp[i], dp[i-2]+1)
  return dp[^1]

var res = n
for a in btn:
  for b in btn:
    for c in btn:
      for d in btn:
        res = min(res, cnt(cs, @[a&b, c&d]))

echo res

Submission Info

Submission Time
Task C - コマンド入力
User glia269
Language Nim (0.13.0)
Score 100
Code Size 563 Byte
Status AC
Exec Time 14 ms
Memory 640 KB

Compile Error

Hint: system [Processing]
Hint: Main [Processing]
Hint: sequtils [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint:  [Link]
Hint: operation successful (12957 lines compiled; 1.886 sec total; 14.143MB; Release Build) [SuccessX]

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 45
Set Name Test Cases
All 00_retmax.txt, 00_retmin.txt, 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_twothree_00.txt, 02_twothree_01.txt, 02_twothree_02.txt, 02_twothree_03.txt, 02_twothree_04.txt, 02_twothree_05.txt, 02_twothree_06.txt, 02_twothree_07.txt, 02_twothree_08.txt, 02_twothree_09.txt, 02_twothree_10.txt, 02_twothree_11.txt, 02_twothree_12.txt, 02_twothree_13.txt, 02_twothree_14.txt, 02_twothree_15.txt, 02_twothree_16.txt, 02_twothree_17.txt, 02_twothree_18.txt, 02_twothree_19.txt
Case Name Status Exec Time Memory
00_retmax.txt AC 12 ms 640 KB
00_retmin.txt AC 1 ms 256 KB
00_sample_00.txt AC 1 ms 256 KB
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
01_rnd_00.txt AC 14 ms 640 KB
01_rnd_01.txt AC 14 ms 640 KB
01_rnd_02.txt AC 14 ms 640 KB
01_rnd_03.txt AC 14 ms 640 KB
01_rnd_04.txt AC 14 ms 640 KB
01_rnd_05.txt AC 14 ms 640 KB
01_rnd_06.txt AC 14 ms 640 KB
01_rnd_07.txt AC 14 ms 640 KB
01_rnd_08.txt AC 14 ms 640 KB
01_rnd_09.txt AC 14 ms 640 KB
01_rnd_10.txt AC 14 ms 640 KB
01_rnd_11.txt AC 14 ms 640 KB
01_rnd_12.txt AC 14 ms 640 KB
01_rnd_13.txt AC 14 ms 640 KB
01_rnd_14.txt AC 14 ms 640 KB
01_rnd_15.txt AC 14 ms 640 KB
01_rnd_16.txt AC 14 ms 640 KB
01_rnd_17.txt AC 14 ms 640 KB
01_rnd_18.txt AC 14 ms 640 KB
01_rnd_19.txt AC 14 ms 640 KB
02_twothree_00.txt AC 13 ms 640 KB
02_twothree_01.txt AC 13 ms 640 KB
02_twothree_02.txt AC 13 ms 640 KB
02_twothree_03.txt AC 13 ms 640 KB
02_twothree_04.txt AC 13 ms 640 KB
02_twothree_05.txt AC 13 ms 640 KB
02_twothree_06.txt AC 13 ms 640 KB
02_twothree_07.txt AC 13 ms 640 KB
02_twothree_08.txt AC 13 ms 640 KB
02_twothree_09.txt AC 13 ms 640 KB
02_twothree_10.txt AC 13 ms 640 KB
02_twothree_11.txt AC 13 ms 640 KB
02_twothree_12.txt AC 13 ms 640 KB
02_twothree_13.txt AC 13 ms 640 KB
02_twothree_14.txt AC 13 ms 640 KB
02_twothree_15.txt AC 13 ms 640 KB
02_twothree_16.txt AC 13 ms 640 KB
02_twothree_17.txt AC 13 ms 640 KB
02_twothree_18.txt AC 13 ms 640 KB
02_twothree_19.txt AC 13 ms 640 KB