結果

問題 No.479 頂点は要らない
ユーザー 0w10w1
提出日時 2018-05-08 20:35:10
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 430 ms / 1,500 ms
コード長 859 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 80,148 KB
最終ジャッジ日時 2024-04-21 02:08:06
合計ジャッジ時間 8,502 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
39,552 KB
testcase_01 AC 63 ms
39,424 KB
testcase_02 AC 63 ms
39,552 KB
testcase_03 AC 67 ms
39,296 KB
testcase_04 AC 64 ms
39,296 KB
testcase_05 AC 62 ms
39,552 KB
testcase_06 AC 62 ms
39,424 KB
testcase_07 AC 64 ms
39,424 KB
testcase_08 AC 64 ms
39,552 KB
testcase_09 AC 63 ms
39,552 KB
testcase_10 AC 65 ms
39,168 KB
testcase_11 AC 63 ms
39,424 KB
testcase_12 AC 64 ms
39,552 KB
testcase_13 AC 63 ms
39,424 KB
testcase_14 AC 64 ms
39,296 KB
testcase_15 AC 63 ms
39,424 KB
testcase_16 AC 63 ms
39,296 KB
testcase_17 AC 63 ms
39,552 KB
testcase_18 AC 63 ms
39,168 KB
testcase_19 AC 68 ms
40,320 KB
testcase_20 AC 69 ms
40,192 KB
testcase_21 AC 66 ms
39,808 KB
testcase_22 AC 68 ms
40,064 KB
testcase_23 AC 68 ms
40,064 KB
testcase_24 AC 69 ms
40,320 KB
testcase_25 AC 68 ms
40,192 KB
testcase_26 AC 420 ms
78,588 KB
testcase_27 AC 430 ms
78,592 KB
testcase_28 AC 381 ms
80,148 KB
testcase_29 AC 303 ms
67,316 KB
testcase_30 AC 305 ms
67,696 KB
testcase_31 AC 309 ms
67,696 KB
testcase_32 AC 307 ms
67,436 KB
testcase_33 AC 319 ms
66,104 KB
testcase_34 AC 316 ms
66,792 KB
testcase_35 AC 265 ms
63,488 KB
testcase_36 AC 197 ms
57,052 KB
testcase_37 AC 348 ms
68,716 KB
testcase_38 AC 281 ms
67,304 KB
testcase_39 AC 235 ms
65,368 KB
testcase_40 AC 291 ms
67,392 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