結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,100 KB
testcase_01 AC 83 ms
15,056 KB
testcase_02 WA -
testcase_03 AC 84 ms
15,264 KB
testcase_04 AC 84 ms
15,192 KB
testcase_05 AC 84 ms
15,104 KB
testcase_06 AC 83 ms
15,288 KB
testcase_07 WA -
testcase_08 AC 81 ms
15,160 KB
testcase_09 WA -
testcase_10 AC 648 ms
35,636 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|
		x=dfs(e,d+1)
		r=[r||9999999,x+1].min
	}
	R[n]=[r||0,d].min
	r||0
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