← All problemsSign in

Scalar Product Tree

CodeChefRating 2527Open on judge ↗

Chef has a tree with $N$ vertices (numbered $1$ through $N$). The tree is rooted at the vertex $1$. For each valid $i$, the weight of the $i$-th vertex is $w_i$. For a vertex $u$ with depth $d$ (the root has depth $1$), let's denote the sequence of vertices on the path from $u$ to the root by $(v_1, v_2, \ldots, v_d)$, where $v_1 = u$ and $v_d = 1$. Then, let $F_u$ be the vector (i.e. sequence)

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