Given a tree with nodes, each with a value. Process queries:
Update: change the value of node to
Query: find the maximum value on the path from to Constraints: . You're solving the classic HLD problem. The tree structure prevents using standard segment trees directly. HLD breaks the tree into chains, each handled by a segment tree. Before reading the solution, think about why sqrt decomposition wouldn't work well here.