Tree Height
CodeChefOpen on judge ↗
Flippy the bird has a tree with $N$ nodes. Each edge has a weight $w_{i}$. We can choose one of the vertices as the root of the tree, say $r$. Then, the height of the node $u$ would be the sum of the weights on the path from $r$ to $u$. Suppose we take the node $u$ as the root. What is the sum of the heights of all nodes? Answer this question for all possible nodes $u$. ### Input - The firs
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