Tree Query
CodeChefOpen on judge ↗
You are given a [tree](https://en.wikipedia.org/wiki/Tree_(graph_theory)) with $N$ vertices rooted at vertex $1$, where $ith$ vertex having a value $A_i$. You are also given $Q$ queries where each query gives you a node $u$ and a value $val$. You need to add $val$ to each node $v$ such that $v$ is in the subtree of $u$ ###Input: - First line will contain $N$ and $Q$, number of nodes and queries
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