#P3273. [SCOI2011] 棘手的操作
[SCOI2011] 棘手的操作
Description
There are nodes labeled from to , initially all disconnected. The initial weight of the -th node is . Then the following operations occur:
U x y: add an edge connecting node and node .A1 x v: increase the weight of node by .A2 x v: increase the weights of all nodes in the connected component containing node by .A3 v: increase the weights of all nodes by .F1 x: output the current weight of node .F2 x: output the maximum weight within the connected component containing node .F3: output the maximum weight among all nodes.
Input Format
The first line contains an integer , the number of nodes. The second line contains integers , the initial weights of the nodes.
The next line contains an integer , the number of subsequent operations.
Each of the following lines is in one of the formats described above.
Output Format
For operations F1 x, F2 x, and F3, output the corresponding result, one per line.
3
0 0 0
8
A1 3 -20
A1 2 20
U 1 3
A2 1 10
F1 3
F2 3
A3 -10
F3
-10
10
10
Hint
Constraints:
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , .
- For all testdata, the input is guaranteed to be valid, and .
Translated by ChatGPT 5
京公网安备 11011102002149号