結果
問題 |
No.806 木を道に
|
ユーザー |
|
提出日時 | 2019-07-23 20:23:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 523 ms / 2,000 ms |
コード長 | 314 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 32,660 KB |
最終ジャッジ日時 | 2024-06-26 08:24:00 |
合計ジャッジ時間 | 7,564 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
from collections import defaultdict N = int(input()) adj_dict = defaultdict(list) for _ in range(N-1): a_i, b_i = map(int, input().split()) adj_dict[a_i].append(b_i) adj_dict[b_i].append(a_i) degree1 = 0 for i in range(1, N+1): if len(adj_dict[i]) == 1: degree1 += 1 print(degree1 - 2)