You are given a tree with nodes. Edges have weights. Process queries: CHANGE changes the weight of edge to , and QUERY finds the maximum edge weight on the path from to . Constraints: , .
Edge weights can be negative. The tree is given as a list of edges with their weights and indices. This is an edge-weighted tree problem, different from vertex-weighted problems. You need to map edges to nodes carefully. Read the full problem at SPOJ.