結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,976 KB
testcase_01 AC 84 ms
15,976 KB
testcase_02 AC 86 ms
15,976 KB
testcase_03 AC 85 ms
15,976 KB
testcase_04 AC 85 ms
15,976 KB
testcase_05 AC 86 ms
15,976 KB
testcase_06 AC 85 ms
15,976 KB
testcase_07 AC 84 ms
15,976 KB
testcase_08 AC 84 ms
15,976 KB
testcase_09 AC 85 ms
15,976 KB
testcase_10 WA -
testcase_11 AC 84 ms
15,976 KB
testcase_12 AC 85 ms
15,976 KB
testcase_13 AC 117 ms
17,368 KB
testcase_14 AC 119 ms
17,304 KB
testcase_15 AC 119 ms
17,316 KB
testcase_16 AC 117 ms
17,368 KB
testcase_17 AC 117 ms
17,336 KB
testcase_18 AC 184 ms
20,932 KB
testcase_19 WA -
testcase_20 AC 216 ms
22,468 KB
testcase_21 AC 295 ms
25,512 KB
testcase_22 AC 352 ms
26,732 KB
testcase_23 AC 477 ms
35,592 KB
testcase_24 AC 481 ms
35,060 KB
testcase_25 AC 486 ms
35,584 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