結果
問題 |
No.277 根掘り葉掘り
|
ユーザー |
|
提出日時 | 2015-09-04 22:41:29 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 517 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 41,216 KB |
最終ジャッジ日時 | 2024-07-19 01:14:11 |
合計ジャッジ時間 | 7,968 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 6 TLE * 1 -- * 5 |
ソースコード
def dfs(i, d): R[i] = d for j in chil[i]: dfs(j, d + 1) def up(i, d): L[i] = min(L[i], d) for j in par[i]: up(j, d + 1) N = int(raw_input()) par, chil = [[] for i in xrange(N)], [[] for i in xrange(N)] for loop in xrange(N - 1): x, y = map(int, raw_input().split()) x -= 1 y -= 1 chil[x].append(y) par[y].append(x) R, L = [0] * N, [1e9] * N dfs(0, 0) for i in xrange(N): if len(chil[i]) == 0: up(i, 0) for i in xrange(N): print min(R[i], L[i])