#P4315. 月下“毛景树”
月下“毛景树”
Description
Crawl, crawl~ crawl, crawl~~ The caterpillar crawled under a small "Maojing Tree" and found that it bore its favorite maomao fruits. The "Maojing Tree" has nodes and edges. There are no maomao fruits on the nodes; all maomao fruits grow on the edges. This "Maojing Tree" has magical power: it can change the number of maomao fruits on its edges:
Change k w: Set the number of maomao fruits on the -th edge to .Cover u v w: Set the number of maomao fruits on every edge along the path between nodes and to .Add u v w: Increase by the number of maomao fruits on every edge along the path between nodes and .
Since the caterpillar is greedy, it will ask the following query:
Max u v: Query the maximum number of maomao fruits among all edges along the path between nodes and .
Input Format
The first line contains a positive integer .
The next lines each contain three positive integers , , and . The -th line describes the -th edge: it connects nodes and , and there are maomao fruits on that edge.
Then follow the operations and queries, one per line, terminated by a single line Stop.
Output Format
For each Max query, output its answer on a separate line.
4
1 2 8
1 3 7
3 4 9
Max 2 4
Cover 2 4 5
Add 1 4 10
Change 1 16
Max 2 4
Stop
9
16
Hint
For all testdata, , and the total number of operations and queries does not exceed .
It is guaranteed that at any time, the number of maomao fruits on every edge does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号