結果

問題 No.806 木を道に
ユーザー hiragnhiragn
提出日時 2022-11-29 13:08:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 420 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 32,536 KB
最終ジャッジ日時 2024-10-06 23:59:05
合計ジャッジ時間 5,886 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,496 KB
testcase_01 AC 25 ms
10,624 KB
testcase_02 AC 28 ms
10,624 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 27 ms
10,624 KB
testcase_05 AC 26 ms
10,624 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 26 ms
10,624 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 26 ms
10,624 KB
testcase_10 AC 109 ms
15,984 KB
testcase_11 AC 95 ms
14,592 KB
testcase_12 AC 338 ms
26,580 KB
testcase_13 AC 259 ms
23,124 KB
testcase_14 AC 325 ms
25,972 KB
testcase_15 AC 354 ms
26,956 KB
testcase_16 AC 134 ms
16,860 KB
testcase_17 AC 310 ms
25,248 KB
testcase_18 AC 55 ms
12,288 KB
testcase_19 AC 107 ms
16,104 KB
testcase_20 AC 299 ms
25,000 KB
testcase_21 AC 185 ms
18,544 KB
testcase_22 AC 420 ms
31,400 KB
testcase_23 AC 420 ms
31,532 KB
testcase_24 AC 216 ms
21,688 KB
testcase_25 AC 311 ms
25,652 KB
testcase_26 AC 127 ms
16,656 KB
testcase_27 AC 367 ms
32,536 KB
testcase_28 AC 37 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


def main():
    n = int(input())
    adj = defaultdict(list)
    for _ in range(n - 1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    ans = 0
    for i in range(n + 1):
        ans += max(len(adj[i]) - 2, 0)
    print(ans)


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