結果

問題 No.279 木の数え上げ
コンテスト
ユーザー maimai8
提出日時 2020-08-02 17:08:36
言語 OCaml
(5.5.1)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
MLE  
実行時間 -
コード長 655 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 126 ms
コンパイル使用メモリ 22,688 KB
実行使用メモリ 76,516 KB
最終ジャッジ日時 2026-09-12 07:52:56
合計ジャッジ時間 6,255 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 MLE * 1 -- * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

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