← All problemsSign in

Break And Fix The Tree

CodeChefRating 2827Open on judge ↗

Chef is playing a game, and to win the prize, he must complete it. But he is busy arranging meals for the vortex party, so he asked you the play the game in his place. The game is as below: You are given a rooted tree of size $N$ rooted at node $1$, where each node $i$ has a value $V_i$ assigned to it. Define $P_u$ as the parent of node $u$. You have to perform queries of the following type on th

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