#P5064. [Ynoi Easy Round 2014] 等这场战争结束之后
[Ynoi Easy Round 2014] 等这场战争结束之后
Description
You are given a graph. Each vertex has a weight, and initially there are no edges.
There are some operations:
- Add an undirected edge between and .
- Revert to the state after the -th operation (note that can be , which means reverting to the initial state).
- Query the -th smallest vertex weight among the vertices reachable in the connected component containing . If it does not exist, output .
Input Format
The first line contains two integers , meaning there are vertices and operations.
The next line contains numbers, giving the weight of each vertex.
Then follow lines, each being one of the following three types:
1 x y
2 x
3 x y
Their meanings are as described in the statement.
Output Format
For every operation of type , output one line containing one integer, which is the answer.
6 10
816801151 223885531 110182151 94271893 319888699 106363731
1 1 3
1 3 5
1 2 4
1 4 6
1 1 2
3 1 1
2 4
1 1 2
3 1 4
2 7
94271893
223885531
Hint
Idea: nzhtl1477.
Solution: nzhtl1477( Time , Space ),ccz181078( Time , Space ) ,shadowice1984( Time , Space ) , zx2003( Time , Space ).
Code: nzhtl1477( Time , Space ),ccz181078( Time , Space ) ,shadowice1984( Time , Space ),zx2003( Time , Space ).
Data: nzhtl1477( partially uploaded ).
Constraints: for of the testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号