結果

問題 No.277 根掘り葉掘り
ユーザー TawaraTawara
提出日時 2015-09-05 01:45:05
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 323 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 77,864 KB
実行使用メモリ 92,644 KB
最終ジャッジ日時 2023-09-26 08:25:49
合計ジャッジ時間 6,193 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
76,708 KB
testcase_01 AC 73 ms
76,540 KB
testcase_02 AC 73 ms
76,440 KB
testcase_03 AC 74 ms
76,160 KB
testcase_04 AC 75 ms
76,492 KB
testcase_05 AC 74 ms
76,736 KB
testcase_06 AC 75 ms
76,452 KB
testcase_07 AC 73 ms
76,512 KB
testcase_08 AC 73 ms
76,288 KB
testcase_09 AC 259 ms
92,644 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
e = [[] for i in range(N)]
S = [N]*N
for i in range(N-1):
	x,y = map(int,raw_input().split())
	e[x-1]+=[y-1]
	e[y-1]+=[x-1]
q = [(0,0,0)]+[(0,i,i) for i in range(N) if len(e[i])==1]
while q:
	d,b,h = q.pop(0)
	if d < S[h]:
		S[h] = d
		q+=[(d+1,h,nxt) for nxt in e[h] if nxt != b]
for i in range(N):
	print S[i]
0