B - Counting Distance Arrays
CodeChefOpen on judge ↗
Given a tree with $N$ nodes numbered $1$ to $N$, and a subset of nodes $S$, we define an array $A$ of size $N$ in the following way: - $A_i = \underset{x \in S}{\max} (\text{dist}(x, i))$. Here $\text{dist}(x, y)$ represents the number of edges on the unique shortest path between $x$ and $y$. There are $2^N - 1$ non-empty subsets $S$ possible. Find the number of possible distinct arrays $A$ ove
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