A Tree to Remember
Chef finished inviting all of his friends. Now it is time to get a tree in his house and decorate it for the party. He wants to use the most beautiful tree ever. The tree Chef chose has $N$ nodes (numbered $1$ through $N$) and it is rooted at node $1$. For each valid $i$, the initial colour of the $i$-th node is $C_i$ and there is a value $A_i$ written in that node. Chef calculates the *beauty*
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