結果

問題 No.279 木の数え上げ
ユーザー maimai8maimai8
提出日時 2020-08-02 17:08:36
言語 OCaml
(5.1.0)
結果
MLE  
実行時間 -
コード長 655 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 21,572 KB
実行使用メモリ 112,432 KB
最終ジャッジ日時 2024-04-17 09:07:59
合計ジャッジ時間 3,948 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
  let rec charlist_of_string str n i =
    if i = n then []
    else str.[i] :: charlist_of_string str n (i+1) in
  let rec search lst target = match lst with
    | [] -> raise Not_found
    | h :: t -> if h = target then t else h :: search t target in
  Scanf.scanf "%s\n" @@ fun s ->
  let lst = ref (charlist_of_string s (String.length s) 0) in
  let flag = ref true in
  let ans = ref 0 in
  while !flag do
    try 
      let l = search !lst 't' in
      let l = search l 'r' in
      let l = search l 'e' in
      let l = search l 'e' in
      lst := l; ans := !ans + 1
    with Not_found -> flag := false
  done;
  Printf.printf "%d\n" !ans
0