Submission #1359977


Source Code Expand

module CharSet = Set.Make (Char)

let rec solve n c s =
  if List.for_all (( = ) c) @@ Array.to_list s then n
  else
    solve (n + 1) c (Array.init (Array.length s - 1) (fun i ->
      if s.(i) = c || s.(i + 1) = c then c
      else s.(i)))
let solve = solve 0

let () =
  let s = read_line () in
  let a = Array.init (String.length s) (fun i -> s.[i]) in
  CharSet.of_list (Array.to_list a)
  |> CharSet.elements
  |> List.map (fun c -> solve c a)
  |> List.fold_left min max_int
  |> Printf.printf "%d\n"

Submission Info

Submission Time
Task A - Shrinking
User fetburner
Language OCaml (4.02.3)
Score 300
Code Size 524 Byte
Status AC
Exec Time 5 ms
Memory 2560 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 14
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
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 384 KB
0_01.txt AC 1 ms 384 KB
0_02.txt AC 1 ms 384 KB
0_03.txt AC 1 ms 640 KB
1_00.txt AC 1 ms 384 KB
1_01.txt AC 1 ms 640 KB
1_02.txt AC 1 ms 384 KB
1_03.txt AC 1 ms 384 KB
1_04.txt AC 1 ms 512 KB
1_05.txt AC 1 ms 640 KB
1_06.txt AC 2 ms 1024 KB
1_07.txt AC 2 ms 1152 KB
1_08.txt AC 4 ms 2560 KB
1_09.txt AC 5 ms 2560 KB