← All problemsSign in

Ghost Chase

CodeChefRating 3062Open on judge ↗

Chef is collecting special ingredients in a cave. The cave has $N$ chambers and $N-1$ passageways forming a tree. In other words, it is possible to move from one chamber to any other chamber using the passageways. Each passageway is of equal length and can be traversed in both directions. At $0$-th second, Chef is at chamber $A_j$. At the start of each second, he can choose to either stay in the

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