結果
問題 | No.277 根掘り葉掘り |
ユーザー | TANIGUCHI Kousuke |
提出日時 | 2015-09-08 23:09:23 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 450 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 11,416 KB |
実行使用メモリ | 20,392 KB |
最終ジャッジ日時 | 2023-09-26 10:11:20 |
合計ジャッジ時間 | 6,433 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
15,176 KB |
testcase_01 | AC | 80 ms
15,100 KB |
testcase_02 | WA | - |
testcase_03 | AC | 81 ms
15,264 KB |
testcase_04 | AC | 83 ms
15,024 KB |
testcase_05 | WA | - |
testcase_06 | AC | 83 ms
15,052 KB |
testcase_07 | WA | - |
testcase_08 | AC | 81 ms
15,144 KB |
testcase_09 | WA | - |
testcase_10 | AC | 401 ms
20,392 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
コンパイルメッセージ
Syntax OK
ソースコード
# Here your code ! INF = 10 ** 8 n = gets.to_i P = Array.new(n+1,1) R = Array.new(n+1,0) L = Array.new(n+1,INF) leaf = Array.new(n+1,true) (n - 1).times do from, to = gets.split.map(&:to_i) P[to] = from R[to] = R[from] + 1 leaf[from] = false end (1..n).select {|v| leaf[v]}.each do |i| d = R[i] + 1 d.times.inject(i) do |j, dep| L[j] = [L[j], dep].min P[j] end end puts (1..n).map {|i| [R[i], L[i]].min }