結果

問題 No.763 Noelちゃんと木遊び
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-11-21 09:26:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 44,404 KB
最終ジャッジ日時 2023-09-04 14:20:25
合計ジャッジ時間 9,767 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 398 ms
44,404 KB
testcase_01 AC 160 ms
14,028 KB
testcase_02 AC 388 ms
21,704 KB
testcase_03 AC 259 ms
17,584 KB
testcase_04 AC 181 ms
14,980 KB
testcase_05 AC 250 ms
17,020 KB
testcase_06 AC 480 ms
24,428 KB
testcase_07 AC 464 ms
24,036 KB
testcase_08 AC 269 ms
17,920 KB
testcase_09 AC 177 ms
14,644 KB
testcase_10 AC 75 ms
10,568 KB
testcase_11 AC 511 ms
24,932 KB
testcase_12 AC 436 ms
23,056 KB
testcase_13 AC 435 ms
22,748 KB
testcase_14 AC 371 ms
21,168 KB
testcase_15 AC 253 ms
17,332 KB
testcase_16 AC 52 ms
9,656 KB
testcase_17 AC 256 ms
17,248 KB
testcase_18 AC 483 ms
24,804 KB
testcase_19 AC 430 ms
23,140 KB
testcase_20 AC 431 ms
23,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
G = [[] for i in range(n)]
for _ in range(n - 1):
	u, v = map(int, input().split())
	u -= 1; v -= 1
	G[u].append(v)
	G[v].append(u)
def dfs(now, prev):
	f = False
	for nex in G[now]:
		if nex == prev: continue
		dfs(nex, now)
		if used[nex]: f = True
	if not f: used[now] = 1
used = [0] * n
dfs(0, -1)
print(sum(used))
0