Graph Theory37 sections · 1633 units
Open in Course

Problems - Path Queries II - Read Statement

(CSES 1138 path maximum)

You are given a tree with nn nodes, each with a value. Process qq queries of two types: update node ss to value xx, or find the maximum value on the path from node aa to node bb. Constraints: 1n,q2000001 \leq n, q \leq 200000. The tree is given as edges.

Values can be up to 10910^9. The tree is connected and has exactly n1n-1 edges. This is a direct application of HLD with a max segment tree. The queries are online, so you must answer each query before seeing the next. Read the full problem at CSES.