結果

問題 No.806 木を道に
ユーザー ronpooronpoo
提出日時 2023-09-19 14:41:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 10,648 KB
実行使用メモリ 28,564 KB
最終ジャッジ日時 2023-09-19 14:42:03
合計ジャッジ時間 6,957 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,852 KB
testcase_01 AC 16 ms
7,952 KB
testcase_02 AC 15 ms
7,836 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 15 ms
7,852 KB
testcase_05 AC 17 ms
7,780 KB
testcase_06 AC 16 ms
7,836 KB
testcase_07 AC 16 ms
7,784 KB
testcase_08 AC 16 ms
7,844 KB
testcase_09 AC 16 ms
7,752 KB
testcase_10 AC 95 ms
12,464 KB
testcase_11 AC 98 ms
12,052 KB
testcase_12 AC 322 ms
25,360 KB
testcase_13 AC 237 ms
20,772 KB
testcase_14 AC 309 ms
24,516 KB
testcase_15 AC 326 ms
25,576 KB
testcase_16 AC 126 ms
14,280 KB
testcase_17 AC 281 ms
23,420 KB
testcase_18 AC 45 ms
9,756 KB
testcase_19 AC 108 ms
12,696 KB
testcase_20 AC 282 ms
23,200 KB
testcase_21 AC 167 ms
16,664 KB
testcase_22 AC 393 ms
28,564 KB
testcase_23 AC 393 ms
28,560 KB
testcase_24 AC 202 ms
18,712 KB
testcase_25 AC 300 ms
24,484 KB
testcase_26 AC 123 ms
14,232 KB
testcase_27 AC 373 ms
28,036 KB
testcase_28 AC 25 ms
8,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]

cnt = [0] *N
for i in range(N-1):
    a, b = ab[i]
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1

ans = 0
for i in range(N):
    ans += max(cnt[i] - 2, 0)
print(ans)
0