結果

問題 No.479 頂点は要らない
ユーザー te-sh
提出日時 2017-12-11 16:09:36
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 82 ms / 1,500 ms
コード長 563 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 102,548 KB
実行使用メモリ 9,368 KB
最終ジャッジ日時 2024-06-12 22:59:37
合計ジャッジ時間 3,708 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], m = rd[1];
  auto g = new int[][](n);
  foreach (i; 0..m) {
    auto rd2 = readln.splitter;
    auto a = rd2.front.to!int; rd2.popFront();
    auto b = rd2.front.to!int;
    g[a] ~= b;
    g[b] ~= a;
  }

  auto b = new bool[](n);
  foreach_reverse (i; 0..n)
    if (!b[i])
      foreach (e; g[i])
        if (e < i)
          b[e] = true;

  b.reverse();

  foreach (bi; b[b.countUntil(true)..$])
    write(bi ? 1 : 0);
  writeln;
}
0