Coins on a tree
CodeChefOpen on judge ↗
Alice is playing a game on an undirected tree, the tree is made up of $N$ nodes numbered from $1$ to $N$. Each node has some coins kept on it, Alice wants to move all the coins on all nodes to a single node on the tree, to do this Alice can do the following move many times : pick any $1$ coin on a node and move that coin to its adjacent node. Alice wants to calculate the minimum number of moves n
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.
Sign in to chat with the tutor and save your progress.
Sign in to start