結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,072 KB
testcase_01 AC 86 ms
16,072 KB
testcase_02 AC 85 ms
16,072 KB
testcase_03 AC 86 ms
16,072 KB
testcase_04 AC 87 ms
16,072 KB
testcase_05 AC 87 ms
16,072 KB
testcase_06 AC 85 ms
16,072 KB
testcase_07 AC 87 ms
16,072 KB
testcase_08 AC 88 ms
16,072 KB
testcase_09 AC 86 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 121 ms
17,464 KB
testcase_14 AC 118 ms
17,412 KB
testcase_15 AC 117 ms
17,412 KB
testcase_16 AC 119 ms
17,464 KB
testcase_17 AC 117 ms
17,432 KB
testcase_18 AC 191 ms
21,028 KB
testcase_19 WA -
testcase_20 AC 228 ms
22,564 KB
testcase_21 AC 294 ms
25,608 KB
testcase_22 AC 376 ms
26,828 KB
testcase_23 AC 497 ms
35,688 KB
testcase_24 AC 500 ms
35,156 KB
testcase_25 AC 534 ms
35,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
mins = [0xffffffff] * n
visited = [b.keys.first]
q = [[b.keys.first, 0]]
until q.empty?
  p, c = q.shift

  b[p].each do |bi|
    next if c + 1 >= mins[bi]

    mins[bi] = c + 1
    visited << bi
    q.push([bi, c + 1])
  end
end
puts visited.uniq.size == n ? 'Bob' : 'Alice'
0