← All problemsSign in

Tree Again

CodeChefRating 2900Open on judge ↗

Misha likes playing DotA and he would do nothing else but play it if he could. Unfortunately for Misha, real life is rough and he has to solve following problem before spending a day playing. You are given a rooted tree with N vertices. Vertices are numerated from 1 to N and vertex 1 is the root of the tree. A positive integer Wi is assigned to every node. Consider following code: Integer sum :=

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