結果
問題 |
No.2427 Tree Distance Two
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:15:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 430 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 82,616 KB |
実行使用メモリ | 159,652 KB |
最終ジャッジ日時 | 2025-03-20 20:16:11 |
合計ジャッジ時間 | 9,037 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
import sys input = sys.stdin.read().split() index = 0 N = int(input[index]) index += 1 adj = [[] for _ in range(N + 1)] for _ in range(N - 1): u = int(input[index]) v = int(input[index + 1]) adj[u].append(v) adj[v].append(u) index += 2 result = [0] * (N + 1) for v in range(1, N + 1): total = 0 for u in adj[v]: total += (len(adj[u]) - 1) result[v] = total for v in range(1, N + 1): print(result[v])