結果

問題 No.479 頂点は要らない
ユーザー 0w10w1
提出日時 2018-05-08 20:35:10
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 445 ms / 1,500 ms
コード長 859 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 95,692 KB
最終ジャッジ日時 2023-08-03 02:34:31
合計ジャッジ時間 10,132 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
42,284 KB
testcase_01 AC 80 ms
42,220 KB
testcase_02 AC 75 ms
42,184 KB
testcase_03 AC 76 ms
42,340 KB
testcase_04 AC 75 ms
42,204 KB
testcase_05 AC 75 ms
42,428 KB
testcase_06 AC 74 ms
42,452 KB
testcase_07 AC 74 ms
42,412 KB
testcase_08 AC 74 ms
42,204 KB
testcase_09 AC 76 ms
42,344 KB
testcase_10 AC 76 ms
42,236 KB
testcase_11 AC 76 ms
42,220 KB
testcase_12 AC 76 ms
42,172 KB
testcase_13 AC 76 ms
42,460 KB
testcase_14 AC 77 ms
42,212 KB
testcase_15 AC 77 ms
42,192 KB
testcase_16 AC 77 ms
42,264 KB
testcase_17 AC 73 ms
42,344 KB
testcase_18 AC 75 ms
42,384 KB
testcase_19 AC 80 ms
43,448 KB
testcase_20 AC 81 ms
43,496 KB
testcase_21 AC 80 ms
42,944 KB
testcase_22 AC 82 ms
43,256 KB
testcase_23 AC 82 ms
43,324 KB
testcase_24 AC 81 ms
43,240 KB
testcase_25 AC 81 ms
43,116 KB
testcase_26 AC 445 ms
93,736 KB
testcase_27 AC 435 ms
93,896 KB
testcase_28 AC 397 ms
95,692 KB
testcase_29 AC 329 ms
78,044 KB
testcase_30 AC 334 ms
77,868 KB
testcase_31 AC 333 ms
77,848 KB
testcase_32 AC 336 ms
77,612 KB
testcase_33 AC 390 ms
81,840 KB
testcase_34 AC 349 ms
78,388 KB
testcase_35 AC 309 ms
71,100 KB
testcase_36 AC 243 ms
60,384 KB
testcase_37 AC 369 ms
79,580 KB
testcase_38 AC 310 ms
68,764 KB
testcase_39 AC 278 ms
65,444 KB
testcase_40 AC 370 ms
82,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {

  let inputs = input.split('\n');

  let n, m;
  [n, m] = inputs[0].split(' ').map((e) => e - 0);

  let a = new Array(m);
  let b = new Array(m);
  for (let i = 0; i < m; ++i) {
    [a[i], b[i]] = inputs[1 + i].split(' ').map((e) => e - 0);
  }

  let g = new Array(n);
  for (let i = 0; i < n; ++i) {
    g[i] = new Array(0);
  }
  for (let i = 0; i < m; ++i) {
    g[a[i]].push(b[i]);
    g[b[i]].push(a[i]);
  }

  let ans = '';
  let killed = new Array(n).fill(false);
  for (let i = n - 1; i >= 0; --i) {
    let must_have = false;
    for (let j = 0; j < g[i].length; ++j) {
      must_have |= killed[g[i][j]];
    }
    if (must_have) {
      ans += '1';
    } else {
      if (ans.length > 0) ans += '0';
      killed[i] = true;
    }
  }

  console.log('%s', ans);

}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
0