| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 1024 MB | 25 | 9 | 9 | 40.909% |
You are given a simple undirected weighted graph with $n+1$ vertices numbered 0,ドル 1, \ldots, n$ and $n + m$ edges.
The weight of an edge between vertices 0ドル$ and $i$ is $a_i$ for 1ドル \leq i \leq n$.
The weight of an edge between vertices $u_i$ and $v_i$ is $w_i$ for 1ドル \leq i \leq m$.
You need to answer $q$ queries, in each query, you are given two integers $i, w$ and you need to change the weight of an edge from 0ドル$ to $i$ to $w$ and find the weight of the minimum spanning tree in the graph.
Note that changes to the weights are permanent, i.e. they stay after each query.
The first line of input contains two numbers $n, m$ (2ドル \leq n \leq 300,000,円 0 \leq m \leq 300,000円$).
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ (1ドル \leq a_i \leq 10^9$).
Each of the next $m$ lines contains three integers $u_i, v_i, w_i$ (1ドル \leq u_i, v_i \leq n, 0 \leq w_i \leq 10^9$).
It is guaranteed that the given graph is simple, in other words, it contains no loops and multiple edges.
The next line contains one integer $q$ (1ドル \leq q \leq 300,000円$).
Each of the next $q$ lines contains two integers $i, w$ (1ドル \leq i \leq n, 1 \leq w \leq 10^9$).
For each query print one integer: the weight of the minimum spanning tree in the graph after the first $i$ queries.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | $n, m, q \leq 2000$ |
| 2 | 10 | All weights are either 1ドル$ or 2ドル$ |
| 3 | 10 | $w = 1$ in all queries |
| 4 | 10 | $i = 1$ in all queries |
| 5 | 10 | $i \le 5$ in all queries |
| 6 | 10 | $m = n - 1, u_i = v_i - 1$ |
| 7 | 20 | $n, m, q \leq 150,000円$ |
| 8 | 20 | No additional constraints |
5 7 3 2 1 2 1 1 5 1 1 3 2 2 5 2 4 5 2 3 4 1 2 4 2 1 2 1 10 3 2 2 3 4 1 3 2 5 1 5 3 3 1 2 3 4 3 5 1
6 6 5 5 5 6 6 6 6 5