結果

問題 No.806 木を道に
ユーザー tktk_snsntktk_snsn
提出日時 2021-08-14 11:50:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 258 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-15 09:15:40
合計ジャッジ時間 4,959 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
10,880 KB
testcase_01 AC 38 ms
10,880 KB
testcase_02 AC 34 ms
10,624 KB
testcase_03 AC 34 ms
10,752 KB
testcase_04 AC 35 ms
10,624 KB
testcase_05 AC 39 ms
10,624 KB
testcase_06 AC 36 ms
10,752 KB
testcase_07 AC 34 ms
10,752 KB
testcase_08 AC 34 ms
10,624 KB
testcase_09 AC 35 ms
10,752 KB
testcase_10 AC 82 ms
11,008 KB
testcase_11 AC 73 ms
10,752 KB
testcase_12 AC 204 ms
11,392 KB
testcase_13 AC 162 ms
11,264 KB
testcase_14 AC 199 ms
11,264 KB
testcase_15 AC 211 ms
11,392 KB
testcase_16 AC 99 ms
10,752 KB
testcase_17 AC 187 ms
11,392 KB
testcase_18 AC 53 ms
10,752 KB
testcase_19 AC 80 ms
10,752 KB
testcase_20 AC 184 ms
11,392 KB
testcase_21 AC 120 ms
10,880 KB
testcase_22 AC 243 ms
11,520 KB
testcase_23 AC 244 ms
11,520 KB
testcase_24 AC 132 ms
11,008 KB
testcase_25 AC 186 ms
11,264 KB
testcase_26 AC 91 ms
10,880 KB
testcase_27 AC 220 ms
11,392 KB
testcase_28 AC 44 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
deg = [0] * N
for _ in range(N-1):
    a, b = map(int, input().split())
    deg[a-1] += 1
    deg[b-1] += 1

ans = 0
for d in deg:
    ans += max(0, d-2)
print(ans)
0