CF1416D.Graph and Queries

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

    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
首页