← All problemsSign in

Eating Chocolates

There is an undirected tree with $N$ nodes numbered $1$ to $N$ rooted at $1$. Each node is having exactly one chocolate initially. There is a magician performing a spell at a certain node $p$ given by query $[1$ $p$ $k]$. After performing the spell, the number of chocolates is multiplied by $k$ for each node in the subtree rooted at $p$. All the chocolates present at a node will be distinct at all

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