CF487E.Tourists

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There are nn cities in Cyberland, numbered from 11 to nn , connected by mm bidirectional roads. The jj -th road connects city aja_{j} and bjb_{j} .

For tourists, souvenirs are sold in every city of Cyberland. In particular, city ii sell it at a price of wiw_{i} .

Now there are qq queries for you to handle. There are two types of queries:

  • "C aa ww ": The price in city aa is changed to ww .
  • "A aa bb ": Now a tourist will travel from city aa to bb . He will choose a route, he also doesn't want to visit a city twice. He will buy souvenirs at the city where the souvenirs are the cheapest (possibly exactly at city aa or bb ). You should output the minimum possible price that he can buy the souvenirs during his travel.

More formally, we can define routes as follow:

  • A route is a sequence of cities \[x_{1},x_{2},...,x_{k}\] , where kk is a certain positive integer.
  • For any 1<=i<j<=k,xixj1<=i<j<=k,x_{i}≠x_{j} .
  • For any 1<=i<k1<=i<k , there is a road connecting xix_{i} and xi+1x_{i+1} .
  • The minimum price of the route is min(wx1,wx2,...,wxk)min(w_{x1},w_{x2},...,w_{xk}) .
  • The required answer is the minimum value of the minimum prices of all valid routes from aa to bb .

输入格式

The first line of input contains three integers n,m,q(1n,m,q105)n, m, q (1 \leq n, m, q \leq 10^5), separated by a single space.

Next n lines contain integers wi(1wi109)w_i (1 \leq w_i \leq 10^9).

Next m lines contain pairs of space-separated integers aja_j and bjb_j (1aj,bjn,ajbj)(1 \leq a_j, b_j \leq n, aj \neq bj).

It is guaranteed that there is at most one road connecting the same pair of cities. There is always at least one valid route between any two cities.

Next qq lines each describe a query. The format is "C a w" or "A a b" (1a,bn,1w109)(1 \leq a, b \leq n, 1 \leq w \leq 10^9).

输出格式

For each query of type "A", output the corresponding answer.

输入输出样例

  • 输入#1

    3 3 3
    1
    2
    3
    1 2
    2 3
    1 3
    A 2 3
    C 1 5
    A 2 3
    

    输出#1

    1
    2
    
  • 输入#2

    7 9 4
    1
    2
    3
    4
    5
    6
    7
    1 2
    2 5
    1 5
    2 3
    3 4
    2 4
    5 6
    6 7
    5 7
    A 2 3
    A 6 4
    A 6 7
    A 3 3
    

    输出#2

    2
    1
    5
    3
    

说明/提示

There are nn cities in Cyberland, numbered from 11 to nn , connected by mm bidirectional roads. The jj -th road connects city aja_{j} and bjb_{j} .

For tourists, souvenirs are sold in every city of Cyberland. In particular, city ii sell it at a price of wiw_{i} .

Now there are qq queries for you to handle. There are two types of queries:

  • "C aa ww ": The price in city aa is changed to ww .
  • "A aa bb ": Now a tourist will travel from city aa to bb . He will choose a route, he also doesn't want to visit a city twice. He will buy souvenirs at the city where the souvenirs are the cheapest (possibly exactly at city aa or bb ). You should output the minimum possible price that he can buy the souvenirs during his travel.

More formally, we can define routes as follow:

  • A route is a sequence of cities \[x_{1},x_{2},...,x_{k}\] , where kk is a certain positive integer.
  • For any 1<=i<j<=k,xixj1<=i<j<=k,x_{i}≠x_{j} .
  • For any 1<=i<k1<=i<k , there is a road connecting xix_{i} and xi+1x_{i+1} .
  • The minimum price of the route is min(wx1,wx2,...,wxk)min(w_{x1},w_{x2},...,w_{xk}) .
  • The required answer is the minimum value of the minimum prices of all valid routes from aa to bb .
首页