You are given a tree with nodes, each with a value. Process queries of two types: update node to value , or find the maximum value on the path from node to node . Constraints: . The tree is given as edges.
Values can be up to . The tree is connected and has exactly 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.