CF1416D

Graph and Queries

题目描述

You are given an undirected graph consisting of nn vertices and mm edges. Initially there is a single integer written on every vertex: the vertex ii has pip_i written on it. All pip_i are distinct integers from 11 to nn .

You have to process qq queries of two types:

  • 11 vv — among all vertices reachable from the vertex vv using the edges of the graph (including the vertex vv itself), find a vertex uu with the largest number pup_u written on it, print pup_u and replace pup_u with 00 ;
  • 22 ii — delete the ii -th edge from the graph.

Note that, in a query of the first type, it is possible that all vertices reachable from vv have 00 written on them. In this case, uu is not explicitly defined, but since the selection of uu does not affect anything, you can choose any vertex reachable from vv and print its value (which is 00 ).

输入格式

The first line contains three integers nn , mm and qq ( 1n21051 \le n \le 2 \cdot 10^5 ; 1m31051 \le m \le 3 \cdot 10^5 ; 1q51051 \le q \le 5 \cdot 10^5 ).

The second line contains nn distinct integers p1p_1 , p2p_2 , ..., pnp_n , where pip_i is the number initially written on vertex ii ( 1pin1 \le p_i \le n ).

Then mm lines follow, the ii -th of them contains two integers aia_i and bib_i ( 1ai,bin1 \le a_i, b_i \le n , aibia_i \ne b_i ) and means that the ii -th edge connects vertices aia_i and bib_i . It is guaranteed that the graph does not contain multi-edges.

Then qq lines follow, which describe the queries. Each line is given by one of the following formats:

  • 11 vv — denotes a query of the first type with a vertex vv ( 1vn1 \le v \le n ).
  • 22 ii — denotes a query of the second type with an edge ii ( 1im1 \le i \le m ). 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 pup_u written on the chosen vertex uu .

输入输出样例

输入样例 #1

text
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

text
5
1
2
0

题解

0 篇题解

登录后即可使用 Markdown 发布题解。

登录 / 注册

还没有题解,来发布第一篇吧。

讨论

0 条讨论

登录后即可使用 Markdown 发起讨论和回复。

登录 / 注册

还没有讨论,来发起第一条吧。