結果
問題 |
No.763 Noelちゃんと木遊び
|
ユーザー |
|
提出日時 | 2021-11-21 09:26:24 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 540 ms / 2,000 ms |
コード長 | 377 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 46,592 KB |
最終ジャッジ日時 | 2025-03-22 10:40:29 |
合計ジャッジ時間 | 9,855 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
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))