結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
|
| 提出日時 | 2017-01-30 00:59:09 |
| 言語 | OCaml (5.2.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,011 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-11-14 19:55:46 |
| 合計ジャッジ時間 | 1,570 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
File "Main.ml", line 35, characters 14-25:
35 | and ab_st = Stream.from (
^^^^^^^^^^^
Error: Unbound module Stream
ソースコード
let readln_t2_by f =
let ( @@ ) lst n = List.nth lst n in
read_line ()
|> Str.split (Str.regexp_string " ")
|> List.map f
|> fun lst -> (lst @@ 0, lst @@ 1)
let solve n arr =
let tbl = Hashtbl.create n
and ans = Bytes.make (n - 1) '0'
in
Hashtbl.add tbl (n - 1) false;
let rec solve' idx =
if idx < 0 then ()
else
(
let buy_flg =
List.exists (fun b -> not (Hashtbl.find tbl b)) arr.(idx)
in
Hashtbl.add tbl idx buy_flg;
if buy_flg then (Bytes.set ans (n - 2 - idx) '1');
solve' (idx - 1)
)
in
solve' (n - 2);
let sidx = Bytes.index ans '1' in
Bytes.sub_string ans sidx (n - 1 - sidx)
let () =
let n, m = readln_t2_by int_of_string in
let ab_arr = Array.make (n - 1) []
and ab_st = Stream.from (
fun i ->
if i < m then
let a, b = readln_t2_by int_of_string in
Some(a, b)
else None)
in
Stream.iter (fun (a, b) -> ab_arr.(a) <- b :: ab_arr.(a)) ab_st;
solve n ab_arr |> print_endline