Graph Theory37 sections · 1633 units
Open in Course

Problem - Path Queries II

CSES Tree, path max with up...

You are given a tree where each node has a value. Process two types of queries:

1.1. Change the value of node s to x (update query).

2.2. Find the maximum value on the path from node a to node b (path query).

There are up to 200200,000000 nodes and 200200,000000 queries mixed together. Updates and path queries can be interleaved. This requires a data structure that handles both path queries and point updates efficiently. Heavy-light decomposition with a segment tree is the standard approach.