結果

問題 No.806 木を道に
ユーザー maburoemaburoe
提出日時 2019-05-17 15:36:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 11,728 KB
実行使用メモリ 10,652 KB
最終ジャッジ日時 2023-10-17 07:20:53
合計ジャッジ時間 5,527 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,996 KB
testcase_01 AC 29 ms
9,996 KB
testcase_02 AC 29 ms
9,996 KB
testcase_03 AC 29 ms
9,996 KB
testcase_04 AC 29 ms
9,996 KB
testcase_05 AC 30 ms
9,996 KB
testcase_06 AC 29 ms
9,996 KB
testcase_07 AC 29 ms
9,996 KB
testcase_08 AC 29 ms
9,996 KB
testcase_09 AC 29 ms
9,996 KB
testcase_10 AC 98 ms
10,124 KB
testcase_11 AC 90 ms
10,124 KB
testcase_12 AC 292 ms
10,388 KB
testcase_13 AC 213 ms
10,388 KB
testcase_14 AC 275 ms
10,388 KB
testcase_15 AC 292 ms
10,652 KB
testcase_16 AC 124 ms
10,124 KB
testcase_17 AC 257 ms
10,388 KB
testcase_18 AC 54 ms
10,072 KB
testcase_19 AC 99 ms
10,124 KB
testcase_20 AC 258 ms
10,388 KB
testcase_21 AC 158 ms
10,124 KB
testcase_22 AC 334 ms
10,652 KB
testcase_23 AC 332 ms
10,652 KB
testcase_24 AC 188 ms
10,388 KB
testcase_25 AC 270 ms
10,388 KB
testcase_26 AC 121 ms
10,124 KB
testcase_27 AC 315 ms
10,652 KB
testcase_28 AC 37 ms
10,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

node_num = int(input())

nodes_count = [0] * node_num

answer = 0
for i in range(node_num - 1):
    first, second = map(int, input().split())
    firstIndex = first - 1
    secondIndex = second - 1

    if nodes_count[firstIndex] == 2:
        answer += 1
    else:
        nodes_count[firstIndex] += 1

    if nodes_count[secondIndex] == 2:
        answer += 1
    else:
        nodes_count[secondIndex] += 1

print(answer)
0