結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-01-31 23:24:25
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 348 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 17,432 KB
最終ジャッジ日時 2023-10-17 12:39:20
合計ジャッジ時間 11,056 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,072 KB
testcase_01 AC 85 ms
16,072 KB
testcase_02 AC 86 ms
16,072 KB
testcase_03 AC 85 ms
16,072 KB
testcase_04 AC 85 ms
16,072 KB
testcase_05 AC 85 ms
16,072 KB
testcase_06 AC 84 ms
16,072 KB
testcase_07 AC 85 ms
16,072 KB
testcase_08 AC 84 ms
16,072 KB
testcase_09 AC 85 ms
16,072 KB
testcase_10 WA -
testcase_11 AC 86 ms
16,072 KB
testcase_12 AC 85 ms
16,072 KB
testcase_13 AC 1,037 ms
17,356 KB
testcase_14 AC 767 ms
17,112 KB
testcase_15 AC 764 ms
17,084 KB
testcase_16 AC 1,049 ms
17,356 KB
testcase_17 AC 1,064 ms
17,432 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
b = {}
(n-1).times do
  u, v = gets.chomp.split.map(&:to_i)

  b[u] ||= []
  b[u] << v
  b[v] ||= []
  b[v] << u
end
s = b.keys.first
visited = [s]
q = [s]
until q.empty?
  p = q.shift

  b[p].each do |bi|
    next if visited.include?(bi)

    visited << bi
    q.push(bi)
  end
end
puts visited.uniq.size == n ? 'Bob' : 'Alice'
0