結果

問題 No.806 木を道に
ユーザー dangodango
提出日時 2023-07-14 18:55:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 288 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 93,952 KB
最終ジャッジ日時 2023-10-14 08:44:22
合計ジャッジ時間 9,772 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 174 ms
80,120 KB
testcase_01 AC 166 ms
80,088 KB
testcase_02 AC 167 ms
80,148 KB
testcase_03 AC 169 ms
80,024 KB
testcase_04 AC 168 ms
80,356 KB
testcase_05 AC 171 ms
80,228 KB
testcase_06 AC 172 ms
80,260 KB
testcase_07 AC 170 ms
79,832 KB
testcase_08 AC 170 ms
80,320 KB
testcase_09 AC 168 ms
80,288 KB
testcase_10 AC 219 ms
85,744 KB
testcase_11 AC 213 ms
85,688 KB
testcase_12 AC 271 ms
93,544 KB
testcase_13 AC 247 ms
89,468 KB
testcase_14 AC 265 ms
91,568 KB
testcase_15 AC 273 ms
93,320 KB
testcase_16 AC 228 ms
87,460 KB
testcase_17 AC 265 ms
91,664 KB
testcase_18 AC 209 ms
84,084 KB
testcase_19 AC 220 ms
85,484 KB
testcase_20 AC 265 ms
91,556 KB
testcase_21 AC 236 ms
87,620 KB
testcase_22 AC 288 ms
93,556 KB
testcase_23 AC 279 ms
93,428 KB
testcase_24 AC 241 ms
89,560 KB
testcase_25 AC 265 ms
91,612 KB
testcase_26 AC 222 ms
85,708 KB
testcase_27 AC 280 ms
93,952 KB
testcase_28 AC 200 ms
84,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List
def main():
    n = int(input().strip())
    abi = [list(map(int, input().strip().split())) for _ in range(n - 1)]
    deg = [0] * (n + 1)
    for ab in abi:
        deg[ab[0]] += 1
        deg[ab[1]] += 1
    ans = 0
    for i in range(1, n + 1):
        ans += max(0, deg[i] - 2)
    print(ans)
main()
0