結果

問題 No.479 頂点は要らない
ユーザー tubo28tubo28
提出日時 2017-01-27 22:58:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 418 ms / 1,500 ms
コード長 513 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,556 KB
実行使用メモリ 38,500 KB
最終ジャッジ日時 2023-08-27 06:49:47
合計ジャッジ時間 9,496 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
15,212 KB
testcase_01 AC 71 ms
15,284 KB
testcase_02 AC 70 ms
15,228 KB
testcase_03 AC 74 ms
15,300 KB
testcase_04 AC 73 ms
15,076 KB
testcase_05 AC 76 ms
15,296 KB
testcase_06 AC 73 ms
15,112 KB
testcase_07 AC 72 ms
15,028 KB
testcase_08 AC 69 ms
15,080 KB
testcase_09 AC 73 ms
15,252 KB
testcase_10 AC 69 ms
15,240 KB
testcase_11 AC 72 ms
15,248 KB
testcase_12 AC 69 ms
15,316 KB
testcase_13 AC 71 ms
15,328 KB
testcase_14 AC 71 ms
14,996 KB
testcase_15 AC 74 ms
15,068 KB
testcase_16 AC 72 ms
15,232 KB
testcase_17 AC 73 ms
15,240 KB
testcase_18 AC 73 ms
15,104 KB
testcase_19 AC 74 ms
15,192 KB
testcase_20 AC 75 ms
15,284 KB
testcase_21 AC 75 ms
15,032 KB
testcase_22 AC 73 ms
15,296 KB
testcase_23 AC 75 ms
15,116 KB
testcase_24 AC 75 ms
15,304 KB
testcase_25 AC 78 ms
15,112 KB
testcase_26 AC 409 ms
37,688 KB
testcase_27 AC 418 ms
37,604 KB
testcase_28 AC 375 ms
38,500 KB
testcase_29 AC 362 ms
34,224 KB
testcase_30 AC 361 ms
34,608 KB
testcase_31 AC 385 ms
34,424 KB
testcase_32 AC 399 ms
34,284 KB
testcase_33 AC 375 ms
32,456 KB
testcase_34 AC 390 ms
33,168 KB
testcase_35 AC 367 ms
29,560 KB
testcase_36 AC 242 ms
23,456 KB
testcase_37 AC 370 ms
32,376 KB
testcase_38 AC 330 ms
31,444 KB
testcase_39 AC 248 ms
25,604 KB
testcase_40 AC 272 ms
29,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m = gets.split.map(&:to_i)

vflg = n.times.map { false }
eflg = m.times.map { false }

adj = n.times.map { [] }
m.times { |i|
  a, b = gets.split.map(&:to_i)
  adj[a] << [i, b]
  adj[b] << [i, a]
}

cnt = 0
n.times { |v|
  adj[v].each { |e, _|
    cnt += 1 unless eflg[e]
    eflg[e] = true
  }
  vflg[v] = true
  break if cnt == m
}

(n-1).downto(0) { |v|
  next unless vflg[v]
  vflg[v] = false if adj[v].all? { |_, u|
    vflg[u]
  }
}

puts vflg.reverse.drop_while { |i| !i }.map { |i| i ? '1' : '0' }.join
0