結果

問題 No.806 木を道に
ユーザー kawacchukawacchu
提出日時 2019-03-22 21:43:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 377 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 11,804 KB
実行使用メモリ 20,280 KB
最終ジャッジ日時 2023-10-19 06:52:08
合計ジャッジ時間 5,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,988 KB
testcase_01 AC 30 ms
9,988 KB
testcase_02 AC 30 ms
9,988 KB
testcase_03 AC 31 ms
9,988 KB
testcase_04 AC 30 ms
9,988 KB
testcase_05 AC 30 ms
9,988 KB
testcase_06 AC 30 ms
9,988 KB
testcase_07 AC 30 ms
9,988 KB
testcase_08 AC 30 ms
9,988 KB
testcase_09 AC 30 ms
9,988 KB
testcase_10 AC 102 ms
12,584 KB
testcase_11 AC 94 ms
11,264 KB
testcase_12 AC 322 ms
15,216 KB
testcase_13 AC 239 ms
15,216 KB
testcase_14 AC 305 ms
15,216 KB
testcase_15 AC 330 ms
15,332 KB
testcase_16 AC 135 ms
12,584 KB
testcase_17 AC 286 ms
15,216 KB
testcase_18 AC 57 ms
10,616 KB
testcase_19 AC 108 ms
12,584 KB
testcase_20 AC 284 ms
15,216 KB
testcase_21 AC 173 ms
12,584 KB
testcase_22 AC 373 ms
20,280 KB
testcase_23 AC 377 ms
20,280 KB
testcase_24 AC 196 ms
15,212 KB
testcase_25 AC 278 ms
15,212 KB
testcase_26 AC 123 ms
12,580 KB
testcase_27 AC 334 ms
20,276 KB
testcase_28 AC 39 ms
10,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

D = {}
for i in range(N-1) :
    a,b = map(int,input().split())
    if a not in D :
        D[a] = 1
    else :
        D[a] += 1
    if b not in D :
        D[b] = 1
    else :
        D[b] += 1

ans = 0
for i in D.values() :
    if i >= 3 :
        ans += i - 2
print(ans)
0