CF1416D

Graph and Queries

NOI/NOI+/CTSC

题目描述

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 ( 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5 ; 1≤m≤3⋅1051 \le m \le 3 \cdot 10^5 ; 1≤q≤5⋅1051 \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 ( 1≤pi≤n1 \le p_i \le n ).

Then mm lines follow, the ii -th of them contains two integers aia_i and bib_i ( 1≤ai,bi≤n1 \le a_i, b_i \le n , ai≠bia_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 ( 1≤v≤n1 \le v \le n ).
  • 22 ii — denotes a query of the second type with an edge ii ( 1≤i≤m1 \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)

登录后即可撰写并分享您的解题思路。

暂无题解,快来发布全站第一篇题解吧!

💬 题目讨论 (0)

登录后可以发起或参与讨论。

暂无讨论内容。

📊 题目信息

题号CF1416D
难度NOI/NOI+/CTSC
时间限制1500 ms
内存限制250 MB
题目来源洛谷题库

⚡ 快速操作

在线提交代码在洛谷打开原题 ↗