← All problemsSign in

XOR Tree

CodeChefRating 2697Open on judge ↗

There is a tree with $N$ vertices, rooted at vertex $1$. Vertex $i$ has the value $A_i$ written on it. Alice walks along this tree, starting at the root. When she is at vertex $u$: - If $u$ has no children, she stops. - Otherwise, suppose $u$ has $c$ children. She picks one of them at random (each one has a $\frac{1}{c}$ probability of being picked), and then moves to it. Alice also has a scor

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