結果

問題 No.277 根掘り葉掘り
ユーザー cielciel
提出日時 2015-09-04 23:31:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 247 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 35,716 KB
最終ジャッジ日時 2023-09-26 07:00:01
合計ジャッジ時間 9,164 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,336 KB
testcase_01 AC 83 ms
15,280 KB
testcase_02 WA -
testcase_03 AC 85 ms
15,084 KB
testcase_04 AC 85 ms
15,020 KB
testcase_05 AC 84 ms
15,292 KB
testcase_06 AC 86 ms
15,144 KB
testcase_07 WA -
testcase_08 AC 83 ms
15,056 KB
testcase_09 WA -
testcase_10 AC 681 ms
35,716 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

ソースコード

diff #

def dfs(n,d)
	r=nil
	H[n].each{|e|
		r||=1<<29
		x=dfs(e,d+1)
		r=[r,x+1].min
	}
	r||=0
	R[n]=[r,d].min
	r
end
		
n=gets.to_i
H=Hash.new{|h,k|h[k]=[]}
R={}
(n-1).times{
	x,y=gets.split.map(&:to_i)
	H[x]<<y
	#H[y]<<x
}
dfs(1,0)
1.step(n){|i|p R[i]}
0