結果

問題 No.571 3人兄弟(その2)
ユーザー ichibanshiboriichibanshibori
提出日時 2017-10-09 17:49:01
言語 OCaml
(5.1.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 645 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 17,152 KB
最終ジャッジ日時 2024-04-17 08:43:52
合計ジャッジ時間 513 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
File "Main.ml", line 3, characters 2-13:
3 |   Stream.iter (fun x -> result := f !result x) st;
      ^^^^^^^^^^^
Error: Unbound module Stream

ソースコード

diff #

let stream_fold f init st =
  let result = ref init in
  Stream.iter (fun x -> result := f !result x) st;
  !result

let stream_to_rev_list st =
  stream_fold (fun result elem -> elem :: result) [] st



let () =
  Stream.from (fun i ->
    if i >= 3 then None
    else
      let c = (65 + i) |> char_of_int
      and h, w =
        read_line ()
        |> fun l -> Scanf.sscanf l "%d %d" (fun h w -> (h, w)) in
      Some(c, h, w))
  |> stream_to_rev_list
  |> List.sort (
    fun (_, h1, w1) (_, h2, w2) ->
	    let c = compare h2 h1 in
	    if c = 0 then compare w1 w2 else c)
  |> List.iter (fun (c, _, _) -> print_endline (String.make 1 c))
0