← All problemsSign in

Perfect Matching

CodeChefRating 2203Open on judge ↗

Chef constructed a tree with $N$ vertices using the following process: - Generate a random array of size $N - 1$ where $1 \le P_i \le i$. All possible arrays satisfying the constraints are equally likely. - Create a tree with only $1$ vertex labelled $1$. - For each $i = 2, 3, \ldots, N$, add a vertex labelled $i$ to the tree, connected with an edge to $P_{i - 1}$. Find the probability that this

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start