結果

問題 No.277 根掘り葉掘り
ユーザー TawaraTawara
提出日時 2015-09-05 00:02:49
言語 PyPy2
(7.3.15)
結果
MLE  
実行時間 -
コード長 444 bytes
コンパイル時間 1,738 ms
コンパイル使用メモリ 77,248 KB
実行使用メモリ 571,440 KB
最終ジャッジ日時 2023-09-26 07:26:12
合計ジャッジ時間 13,622 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
76,340 KB
testcase_01 AC 75 ms
76,068 KB
testcase_02 AC 75 ms
76,344 KB
testcase_03 AC 75 ms
76,380 KB
testcase_04 AC 76 ms
76,352 KB
testcase_05 AC 76 ms
76,344 KB
testcase_06 AC 97 ms
78,664 KB
testcase_07 AC 73 ms
76,260 KB
testcase_08 AC 72 ms
76,564 KB
testcase_09 AC 569 ms
193,852 KB
testcase_10 AC 297 ms
109,068 KB
testcase_11 AC 535 ms
98,784 KB
testcase_12 AC 1,010 ms
190,012 KB
testcase_13 AC 732 ms
98,300 KB
testcase_14 AC 1,167 ms
387,340 KB
testcase_15 MLE -
testcase_16 AC 1,002 ms
306,600 KB
testcase_17 AC 886 ms
265,584 KB
testcase_18 AC 1,002 ms
282,028 KB
testcase_19 AC 715 ms
126,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(1000000)
def dfs(r,b,h,d):
	if RL[h] > d:
		RL[h] = d
		if len(e[h]) == 1 and h != r:
			leaf.add(h)
		else:
			for nxt in e[h]:
				if nxt != b:
					dfs(r,h,nxt,d+1)
N = input()
e = [[] for i in range(N)]
leaf = set([0])
RL = [N]*N
for i in range(N-1):
	x,y = map(int,raw_input().split())
	e[x-1].append(y-1)
	e[y-1].append(x-1)
for i in range(N):
	if i in leaf:
		dfs(i,i,i,0)
for i in range(N):
	print RL[i]
0