結果

問題 No.806 木を道に
ユーザー O2MTO2MT
提出日時 2020-08-31 17:51:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 467 ms / 2,000 ms
コード長 234 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,648 KB
最終ジャッジ日時 2024-04-28 02:26:51
合計ジャッジ時間 6,840 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 29 ms
10,624 KB
testcase_08 AC 30 ms
10,624 KB
testcase_09 AC 29 ms
10,752 KB
testcase_10 AC 118 ms
14,336 KB
testcase_11 AC 112 ms
13,824 KB
testcase_12 AC 392 ms
24,832 KB
testcase_13 AC 290 ms
20,992 KB
testcase_14 AC 375 ms
23,936 KB
testcase_15 AC 395 ms
25,088 KB
testcase_16 AC 159 ms
15,872 KB
testcase_17 AC 351 ms
22,912 KB
testcase_18 AC 63 ms
11,904 KB
testcase_19 AC 126 ms
14,464 KB
testcase_20 AC 337 ms
22,912 KB
testcase_21 AC 203 ms
17,536 KB
testcase_22 AC 467 ms
27,136 KB
testcase_23 AC 466 ms
27,392 KB
testcase_24 AC 225 ms
19,584 KB
testcase_25 AC 324 ms
23,808 KB
testcase_26 AC 138 ms
15,872 KB
testcase_27 AC 397 ms
27,648 KB
testcase_28 AC 41 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i in range(N+1):
  if len(tree[i]) > 2:
    ans += len(tree[i])-2

print(ans)
0