結果

問題 No.806 木を道に
ユーザー mono1120mono1120
提出日時 2019-03-22 22:39:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 11,832 KB
実行使用メモリ 20,356 KB
最終ジャッジ日時 2023-10-19 09:53:09
合計ジャッジ時間 5,981 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,068 KB
testcase_01 AC 29 ms
10,068 KB
testcase_02 AC 30 ms
10,068 KB
testcase_03 AC 29 ms
10,068 KB
testcase_04 AC 30 ms
10,068 KB
testcase_05 AC 30 ms
10,068 KB
testcase_06 AC 30 ms
10,068 KB
testcase_07 AC 30 ms
10,068 KB
testcase_08 AC 30 ms
10,068 KB
testcase_09 AC 30 ms
10,068 KB
testcase_10 AC 107 ms
12,660 KB
testcase_11 AC 97 ms
11,340 KB
testcase_12 AC 330 ms
15,936 KB
testcase_13 AC 248 ms
15,292 KB
testcase_14 AC 317 ms
15,672 KB
testcase_15 AC 331 ms
15,936 KB
testcase_16 AC 137 ms
12,660 KB
testcase_17 AC 292 ms
15,408 KB
testcase_18 AC 57 ms
10,692 KB
testcase_19 AC 111 ms
12,660 KB
testcase_20 AC 293 ms
15,408 KB
testcase_21 AC 175 ms
12,916 KB
testcase_22 AC 386 ms
20,356 KB
testcase_23 AC 385 ms
20,356 KB
testcase_24 AC 201 ms
15,288 KB
testcase_25 AC 286 ms
15,668 KB
testcase_26 AC 131 ms
12,656 KB
testcase_27 AC 366 ms
20,352 KB
testcase_28 AC 40 ms
10,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N = int(input())
d = defaultdict(int)
for _ in range(N-1):
    a, b = [int(i) for i in input().split()]
    d[a] += 1
    d[b] += 1
ans = 0
val = list(d.values())
val.sort()
for i in val:
    if i == 1:
        ans += 1
    else:
        break
print(ans-2)
0