F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Finding a MEX

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 4508    Accepted Submission(s): 975


Problem Description
Given an undirected graph G=(V,E). All vertices are numbered from 1 to N. And every vertex u has a value of $A_u$. Let $S_u$={$A_v$©¦(u,v)¡ÊE}. Also, F(u) equals MEX(minimum excludant) value of $S_u$. A MEX value of a set is the smallest non-negative integer which doesn¡¯t exist in the set.

There are two types of queries.

Type 1: 1 u x ¨C Change $A_u$ to x (0¡Üx¡Ü$10^9$).
Type 2: 2 u ¨C Calculate the value of F(u).

For each query of type 2, you should answer the query.
 

Input
The first line of input contains a single integer T (1¡ÜT¡Ü10) denoting the number of test cases. Each test case begins with a single line containing two integers n (1¡Ün¡Ü$10^5$), m (1¡Üm¡Ü$10^5$) denoting the number of vertices and number of edges in the given graph.

The next line contains n integers and $i^{th}$ of them is a value of $A_i$ (0¡Ü$A_i$¡Ü$10^9$).

The next m lines contain edges of the graph. Every line contains two integers u, v meaning there exist an edge between vertex u and v.

The next line contains a single integer q (1¡Üq¡Ü$10^5$) denoting the number of queries.

The next q lines contain queries described in the description.
 

Output
For each query of type 2, output the value of F(u) in a single line.
 

Sample Input
1 5 4 0 1 2 0 1 1 2 1 3 2 4 2 5 5 2 2 1 2 2 2 2 1 3 1 2 1
 

Sample Output
2 2 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 06:54:06, Gzip enabled