結果

問題 No.806 木を道に
ユーザー AT274_AT274_
提出日時 2019-10-29 18:39:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 426 ms / 2,000 ms
コード長 280 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 10,636 KB
実行使用メモリ 24,924 KB
最終ジャッジ日時 2023-10-12 23:28:13
合計ジャッジ時間 7,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,752 KB
testcase_01 AC 15 ms
7,792 KB
testcase_02 AC 16 ms
7,836 KB
testcase_03 AC 16 ms
7,824 KB
testcase_04 AC 16 ms
7,780 KB
testcase_05 AC 16 ms
7,896 KB
testcase_06 AC 16 ms
7,972 KB
testcase_07 AC 16 ms
7,824 KB
testcase_08 AC 16 ms
7,784 KB
testcase_09 AC 16 ms
7,756 KB
testcase_10 AC 98 ms
11,768 KB
testcase_11 AC 89 ms
11,284 KB
testcase_12 AC 360 ms
22,368 KB
testcase_13 AC 258 ms
18,152 KB
testcase_14 AC 336 ms
21,516 KB
testcase_15 AC 358 ms
22,300 KB
testcase_16 AC 133 ms
13,112 KB
testcase_17 AC 314 ms
20,488 KB
testcase_18 AC 46 ms
9,452 KB
testcase_19 AC 103 ms
11,864 KB
testcase_20 AC 313 ms
20,532 KB
testcase_21 AC 177 ms
14,944 KB
testcase_22 AC 419 ms
24,628 KB
testcase_23 AC 426 ms
24,784 KB
testcase_24 AC 196 ms
16,836 KB
testcase_25 AC 291 ms
21,504 KB
testcase_26 AC 114 ms
13,176 KB
testcase_27 AC 343 ms
24,924 KB
testcase_28 AC 25 ms
8,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
    u, v = map(int, input().split())
    u, v = u - 1, v - 1
    T[u].append(v)
    T[v].append(u)


ans = 0
for i, tos in enumerate(T):
    if len(tos) == 1:
        continue

    ans += len(tos) - 2

print(ans)
0