← All problemsSign in

Batman and Tree

CodeChefRating 2973Open on judge ↗

Nazik gave Batman a tree with $N$ vertices (numbered $1$ through $N$). There are some robbers in the tree; of course, Batman wants to catch the robbers. Initially, Batman is in a vertex $s$ and his power is equal to $p$. During each of the next $M$ seconds, the following process happens: - A robber with power $r$ runs from a vertex $x$ straight to vertex $y$. - Batman either catches the robber or

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