Tree Counting
You are given a rooted tree of $N$ vertices, numbered $1$ to $N$. The tree is rooted at vertex $1$. For a subset $S$, define $f(S)$ as the unique set satisfying the following conditions: - $S \subseteq f(S)$ - For all $x, y \in f(S)$, it is true that $\text{lca}^{\dagger}(x, y) \in f(S)$. - Among all sets satisfying the above $2$ conditions, $|f(S)|$ is as small as possible. For each $K = 1, 2,
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start