Graph and Queries
题目描述
You are given an undirected graph consisting of vertices and edges. Initially there is a single integer written on every vertex: the vertex has written on it. All are distinct integers from to .
You have to process queries of two types:
- — among all vertices reachable from the vertex using the edges of the graph (including the vertex itself), find a vertex with the largest number written on it, print and replace with ;
- — delete the -th edge from the graph.
Note that, in a query of the first type, it is possible that all vertices reachable from have written on them. In this case, is not explicitly defined, but since the selection of does not affect anything, you can choose any vertex reachable from and print its value (which is ).
输入格式
The first line contains three integers , and ( ; ; ).
The second line contains distinct integers , , ..., , where is the number initially written on vertex ( ).
Then lines follow, the -th of them contains two integers and ( , ) and means that the -th edge connects vertices and . It is guaranteed that the graph does not contain multi-edges.
Then lines follow, which describe the queries. Each line is given by one of the following formats:
- — denotes a query of the first type with a vertex ( ).
- — denotes a query of the second type with an edge ( ). For each query of the second type, it is guaranteed that the corresponding edge is not deleted from the graph yet.
输出格式
For every query of the first type, print the value of written on the chosen vertex .
输入输出样例
输入样例 #1
5 4 6
1 2 5 4 3
1 2
2 3
1 3
4 5
1 1
2 1
2 3
1 1
1 2
1 2
输出样例 #1
5
1
2
0
题解
0 篇题解
登录后即可使用 Markdown 发布题解。
登录 / 注册还没有题解,来发布第一篇吧。
讨论
0 条讨论
登录后即可使用 Markdown 发起讨论和回复。
登录 / 注册还没有讨论,来发起第一条吧。