#P4114. Qtree1
Qtree1
Description
Given a tree with nodes, there are two operations:
CHANGE i tset the weight of the -th edge to .QUERY a boutput the maximum edge weight on the path from to . When , output .
Input Format
The first line contains an integer , the number of nodes. Lines through each contain three integers , indicating that there is an edge between and with weight . Starting from line , there are an unspecified number of lines. Each line starts with a string, which can be one of:
CHANGEfollowed by two integers , indicating an update operation.QUERYfollowed by two positive integers , indicating a query operation.DONEindicating the end of input.
Output Format
For each QUERY operation, output one line with a single number: the maximum edge weight on the path between and .
3
1 2 1
2 3 2
QUERY 1 2
CHANGE 1 3
QUERY 1 2
DONE
1
3
Hint
Constraints
For all test points, it is guaranteed that:
- .
- , .
- .
- The number of operations does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号