結果
問題 | No.2427 Tree Distance Two |
ユーザー |
![]() |
提出日時 | 2025-03-20 18:41:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 519 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,904 KB |
実行使用メモリ | 159,484 KB |
最終ジャッジ日時 | 2025-03-20 18:41:46 |
合計ジャッジ時間 | 11,718 ms |
ジャッジサーバーID (参考情報) |
judge3 / 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])