結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
16,100 KB
testcase_01 AC 87 ms
16,100 KB
testcase_02 AC 86 ms
16,100 KB
testcase_03 AC 87 ms
16,100 KB
testcase_04 AC 85 ms
16,100 KB
testcase_05 AC 86 ms
16,100 KB
testcase_06 AC 85 ms
16,100 KB
testcase_07 AC 86 ms
16,096 KB
testcase_08 AC 86 ms
16,100 KB
testcase_09 AC 86 ms
16,100 KB
testcase_10 WA -
testcase_11 AC 86 ms
16,100 KB
testcase_12 AC 85 ms
16,100 KB
testcase_13 AC 118 ms
17,464 KB
testcase_14 RE -
testcase_15 AC 115 ms
17,376 KB
testcase_16 AC 116 ms
17,468 KB
testcase_17 AC 118 ms
17,464 KB
testcase_18 AC 182 ms
20,856 KB
testcase_19 WA -
testcase_20 AC 219 ms
21,804 KB
testcase_21 AC 304 ms
24,316 KB
testcase_22 AC 374 ms
25,272 KB
testcase_23 AC 507 ms
34,172 KB
testcase_24 AC 490 ms
34,416 KB
testcase_25 AC 486 ms
34,240 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
visited = [0]
mins = [0xffffffff] * n
q = [[0, 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