Shikamaru has Queries
CodeChefOpen on judge ↗
Given a tree with $N$ nodes numbered $1$ to $N$ rooted at node $1$, where the $i^{th}$ node has a value $A_i$, answer $Q$ queries of the folowing type. : $a$ $b$ $w$: For all nodes in the simple path between $a$ and $b$, print the sum of values of nodes where value is $<= w$. ###Input: - First line will contain $N$ & $Q$ - Next $N-1$ lines contain $u, v$ representing an edge between
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