Tree Query
CodeChefOpen on judge ↗
You are given a tree with nodes numbered 1 to $n$ that is rooted at node 1. Also $i^{th}$ node has a value $a_i$ assigned to it. You have to answer queries of the following two types: Type 1: $1\ u\ val$, update the value at node $u$ as $v$al. Type 2: $2\ u$, print the sum of squares of values in the subtree (including the node itself) of node $u$. ###Input: - First-line contains an in
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