結果

問題 No.806 木を道に
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-03 15:31:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 271 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 92,332 KB
最終ジャッジ日時 2023-09-29 11:47:04
合計ジャッジ時間 5,955 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,380 KB
testcase_01 AC 71 ms
71,372 KB
testcase_02 AC 70 ms
71,184 KB
testcase_03 AC 72 ms
71,384 KB
testcase_04 AC 70 ms
71,580 KB
testcase_05 AC 72 ms
71,380 KB
testcase_06 AC 73 ms
71,328 KB
testcase_07 AC 70 ms
71,284 KB
testcase_08 AC 71 ms
71,468 KB
testcase_09 AC 72 ms
71,276 KB
testcase_10 AC 125 ms
79,124 KB
testcase_11 AC 121 ms
79,028 KB
testcase_12 AC 193 ms
86,900 KB
testcase_13 AC 166 ms
83,640 KB
testcase_14 AC 187 ms
86,544 KB
testcase_15 AC 199 ms
87,024 KB
testcase_16 AC 131 ms
79,588 KB
testcase_17 AC 181 ms
86,172 KB
testcase_18 AC 117 ms
78,508 KB
testcase_19 AC 121 ms
79,148 KB
testcase_20 AC 182 ms
86,192 KB
testcase_21 AC 148 ms
82,408 KB
testcase_22 AC 218 ms
89,252 KB
testcase_23 AC 218 ms
89,356 KB
testcase_24 AC 131 ms
82,740 KB
testcase_25 AC 151 ms
85,952 KB
testcase_26 AC 118 ms
80,464 KB
testcase_27 AC 173 ms
92,332 KB
testcase_28 AC 98 ms
76,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
g = [[] for i in range(n)]
ind = [0]*n
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)
    ind[a] += 1
    ind[b] += 1

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