結果

問題 No.806 木を道に
ユーザー FromBooskaFromBooska
提出日時 2023-02-28 13:57:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 92,456 KB
最終ジャッジ日時 2023-10-13 20:23:40
合計ジャッジ時間 6,143 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,292 KB
testcase_01 AC 74 ms
71,240 KB
testcase_02 AC 74 ms
71,248 KB
testcase_03 AC 75 ms
71,292 KB
testcase_04 AC 75 ms
71,256 KB
testcase_05 AC 76 ms
71,308 KB
testcase_06 AC 75 ms
71,324 KB
testcase_07 AC 74 ms
71,620 KB
testcase_08 AC 75 ms
71,472 KB
testcase_09 AC 76 ms
71,260 KB
testcase_10 AC 127 ms
79,012 KB
testcase_11 AC 128 ms
78,928 KB
testcase_12 AC 205 ms
86,896 KB
testcase_13 AC 171 ms
83,484 KB
testcase_14 AC 199 ms
86,524 KB
testcase_15 AC 205 ms
86,720 KB
testcase_16 AC 133 ms
79,640 KB
testcase_17 AC 196 ms
86,140 KB
testcase_18 AC 119 ms
78,564 KB
testcase_19 AC 130 ms
78,892 KB
testcase_20 AC 195 ms
86,068 KB
testcase_21 AC 154 ms
82,488 KB
testcase_22 AC 229 ms
89,320 KB
testcase_23 AC 230 ms
89,420 KB
testcase_24 AC 136 ms
82,612 KB
testcase_25 AC 155 ms
86,196 KB
testcase_26 AC 123 ms
80,476 KB
testcase_27 AC 181 ms
92,456 KB
testcase_28 AC 102 ms
76,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 次数が2を超える数の合計でいいのか?

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

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