← All problemsSign in

Hard problem

Professor Vivek had created a test containing set of algorithms problem. Rishabh was able to solve all problems except one hard problem. Where initially in a tree only one node is present, which is node $1$ and is also root of tree. On this tree $Q$ queries needs to be performed. Queries are of two types: $1$ $u$, $v$, $c$: add a new node $v$ to an existing node $u$ with an edge and

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