結果

問題 No.1335 1337
ユーザー esehara
提出日時 2021-06-01 21:19:17
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 20,096 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-09 00:16:22
合計ジャッジ時間 1,067 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

let string_1_list_of_string x =
  String.to_seq x
  |> List.of_seq
  |> List.map (String.make 1);;

let array_of_string s =
  string_1_list_of_string s |> Array.of_list;;

let replace_int s ar =
  let s = string_1_list_of_string s in
  let rec replace_p result s =
    match (s) with
    | [] -> result |> List.rev |> String.concat ""
    | hd::tr ->
      try
        replace_p (ar.(int_of_string hd) :: result) tr
      with 
      | Failure _ -> replace_p (hd::result) tr in
  replace_p [] s;;

let () =
  let a = array_of_string (read_line ()) in
  let s = read_line () in
  replace_int s a |> print_string;
  print_newline ();;
0