結果

問題 No.479 頂点は要らない
ユーザー pekempeypekempey
提出日時 2017-01-27 22:55:55
言語 F#
(F# 4.0)
結果
AC  
実行時間 202 ms / 1,500 ms
コード長 623 bytes
コンパイル時間 10,898 ms
コンパイル使用メモリ 186,624 KB
実行使用メモリ 59,600 KB
最終ジャッジ日時 2024-12-23 16:40:47
合計ジャッジ時間 16,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (276 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

open System

let N, M = Console.ReadLine().Split() |> Array.map int |> fun a -> a.[0], a.[1]

let graph : (int list) array = Array.create N []
let marked = Array.create N false

for _ in 1 .. M do
    let u, v = Console.ReadLine().Split() |> Array.map int |> fun a -> a.[0], a.[1]
    graph.[u] <- v :: graph.[u]
    graph.[v] <- u :: graph.[v]

for i in N - 1 .. -1 .. 0 do
    if graph.[i] |> List.exists (fun j -> j > i && not marked.[j]) then
        marked.[i] <- true

marked
|> Array.rev
|> Array.skipWhile (fun x -> not x)
|> Array.map (fun x -> if x then "1" else "0")
|> System.String.Concat
|> Console.WriteLine
0