結果

問題 No.806 木を道に
ユーザー Takahiro INOUETakahiro INOUE
提出日時 2019-06-07 23:44:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 243 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 32,760 KB
最終ジャッジ日時 2024-04-15 19:26:35
合計ジャッジ時間 7,246 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 29 ms
10,880 KB
testcase_05 AC 28 ms
10,624 KB
testcase_06 AC 27 ms
10,752 KB
testcase_07 AC 27 ms
10,624 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 27 ms
10,624 KB
testcase_10 AC 127 ms
16,108 KB
testcase_11 AC 110 ms
14,584 KB
testcase_12 AC 414 ms
26,700 KB
testcase_13 AC 293 ms
23,252 KB
testcase_14 AC 383 ms
26,096 KB
testcase_15 AC 405 ms
27,084 KB
testcase_16 AC 158 ms
16,984 KB
testcase_17 AC 349 ms
25,116 KB
testcase_18 AC 61 ms
12,416 KB
testcase_19 AC 130 ms
15,972 KB
testcase_20 AC 358 ms
25,000 KB
testcase_21 AC 206 ms
18,800 KB
testcase_22 AC 468 ms
31,644 KB
testcase_23 AC 474 ms
31,656 KB
testcase_24 AC 249 ms
21,812 KB
testcase_25 AC 363 ms
25,904 KB
testcase_26 AC 153 ms
16,904 KB
testcase_27 AC 449 ms
32,760 KB
testcase_28 AC 40 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N = int(input())
E = defaultdict(list)
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
ans = 0
for adj in E.values():
    ans += max(len(adj)-2, 0)
print(ans)
0