結果

問題 No.806 木を道に
ユーザー roarisroaris
提出日時 2019-07-23 20:23:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 314 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,564 KB
実行使用メモリ 30,496 KB
最終ジャッジ日時 2023-09-08 15:21:23
合計ジャッジ時間 8,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,608 KB
testcase_01 AC 17 ms
8,540 KB
testcase_02 AC 18 ms
8,532 KB
testcase_03 AC 18 ms
8,600 KB
testcase_04 AC 18 ms
8,476 KB
testcase_05 AC 18 ms
8,612 KB
testcase_06 AC 18 ms
8,592 KB
testcase_07 AC 18 ms
8,588 KB
testcase_08 AC 18 ms
8,496 KB
testcase_09 AC 19 ms
8,580 KB
testcase_10 AC 102 ms
13,908 KB
testcase_11 AC 90 ms
12,180 KB
testcase_12 AC 351 ms
24,372 KB
testcase_13 AC 262 ms
20,696 KB
testcase_14 AC 334 ms
23,676 KB
testcase_15 AC 359 ms
24,656 KB
testcase_16 AC 135 ms
14,632 KB
testcase_17 AC 314 ms
22,692 KB
testcase_18 AC 47 ms
9,952 KB
testcase_19 AC 105 ms
13,608 KB
testcase_20 AC 307 ms
22,768 KB
testcase_21 AC 175 ms
16,304 KB
testcase_22 AC 428 ms
29,304 KB
testcase_23 AC 426 ms
29,164 KB
testcase_24 AC 197 ms
19,316 KB
testcase_25 AC 286 ms
23,540 KB
testcase_26 AC 121 ms
14,732 KB
testcase_27 AC 371 ms
30,496 KB
testcase_28 AC 28 ms
9,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0