結果

問題 No.806 木を道に
ユーザー tails1434
提出日時 2020-01-08 21:26:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 85,888 KB
最終ジャッジ日時 2024-11-23 03:08:24
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a] += 1
        d[b] += 1

    ans = 0
    for i in d.values():
        ans += max(i-2,0)

    print(ans)



if __name__ == "__main__":
    main()
0