Codeforces Round 278 (Div. 1)
E
Tourists
Codeforces
3200
原题
← D→
翻译中…

There are $*n*$ cities in Cyberland, numbered from $1$ to $*n*$, connected by $*m*$ bidirectional roads. The $*j*$-th road connects city $*a*_{*j*}$ and $*b*_{*j*}$.

翻译中…

For tourists, souvenirs are sold in every city of Cyberland. In particular, city $*i*$ sell it at a price of $*w*_{*i*}$.

翻译中…

Now there are $*q*$ queries for you to handle. There are two types of queries:

翻译中…
  • "C a w": The price in city $*a*$ is changed to $*w*$.
  • "A a b": Now a tourist will travel from city $*a*$ to $*b*$. 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 $*a*$ or $*b*$). 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 $*k*$ is a certain positive integer.
  • For any $1 ≤ *i* < *j* ≤ *k*, *x*_{*i*} ≠ *x*_{*j*}$.
  • For any $1 ≤ *i* < *k*$, there is a road connecting $*x*_{*i*}$ and $*x*_{*i* + 1}$.
  • The minimum price of the route is $*min*(*w*_{*x*_{1}}, *w*_{*x*_{2}}, ..., *w*_{*x*_{*k*}})$.
  • The required answer is the minimum value of the minimum prices of all valid routes from $*a*$ to $*b*$.
翻译中…

Input

翻译中…

The first line of input contains three integers $*n*, *m*, *q*$ ($1 ≤ *n*, *m*, *q* ≤ 10^{5}$), separated by a single space.

翻译中…

Next $*n*$ lines contain integers $*w*_{*i*}$ ($1 ≤ *w*_{*i*} ≤ 10^{9}$).

翻译中…

Next $*m*$ lines contain pairs of space-separated integers $*a*_{*j*}$ and $*b*_{*j*}$ ($1 ≤ *a*_{*j*}, *b*_{*j*} ≤ *n*, *a*_{*j*} ≠ *b*_{*j*}$).

翻译中…

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 $*q*$ lines each describe a query. The format is "C a w" or "A a b" ($1 ≤ *a*, *b* ≤ *n*, 1 ≤ *w* ≤ 10^{9}$).

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

For the second sample, an optimal routes are:

翻译中…

From $2$ to $3$ it is $[2, 3]$.

翻译中…

From $6$ to $4$ it is $[6, 5, 1, 2, 4]$.

翻译中…

From $6$ to $7$ it is $[6, 5, 7]$.

翻译中…

From $3$ to $3$ it is $[3]$.

翻译中…

image

翻译中…

样例

Input #1
3 3 3
1
2
3
1 2
2 3
1 3
A 2 3
C 1 5
A 2 3
Output #1
1
2
InputCopy OutputCopy
Input #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
Output #2
2
1
5
3
InputCopy OutputCopy
题目信息
题号
487E
时间限制
2 s
内存限制
256 MB
标签
数据结构
DFS 及类似
图论
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。