#P11287. Key Point Influence Query

    ID: 13362 Type: Default 1000ms 256MiB

Key Point Influence Query

Key Point Influence Query

You are given an undirected graph with n vertices and m edges. The graph is not necessarily connected, has no self‐loops, and may contain multiple edges. Each vertex i has an associated weight \(a_i\). In addition, some vertices are designated as key points.

The influence of a key point \(u\) is defined as the sum of the weights \(a_i\) of all vertices \(i\) from which \(u\) can be reached without passing through any other key point (that is, the path starting at \(i\) and reaching \(u\) does not have any intermediate key point, and cannot even start from one, except if \(i=u\)).

You have to perform q operations:

  • 1 u x: Update the weight of vertex \(u\) to \(x\), i.e. \(a_u \gets x\).
  • 2 v: Query the influence of the key point \(v\).

Process the operations in order and for each query of type 2, print the corresponding answer.

inputFormat

The input is given as follows:

 n m q k
 a1 a2 ... an
 key1 key2 ... keyk
 u1 v1
 u2 v2
 ...
 um vm
 op1
 op2
 ...
 opq

The first line contains four integers \(n, m, q, k\), where \(k\) is the number of key points.

The second line contains \(n\) space-separated integers \(a_1, a_2, \ldots, a_n\) representing the initial weights of the vertices.

The third line contains \(k\) distinct integers indicating the indices of the key points.

Then follow \(m\) lines, each containing two integers \(u\) and \(v\) (\(1 \le u,v \le n\)) representing an undirected edge between vertices \(u\) and \(v\).

Finally, there are \(q\) lines. Each operation is either of the following two forms:

  • 1 u x : update operation, setting \(a_u = x\).
  • 2 v : query operation, asking for the influence of the key point \(v\).

outputFormat

For each query operation (of type 2), output the computed influence (a single integer) on a new line.

sample

5 4 5 2
1 2 3 4 5
2 4
1 2
2 3
3 4
4 5
2 2
2 4
1 3 10
2 2
2 4
6

12 13 19

</p>