题目链接:https://codeforces.com/contest/1389/problem/G
G. Directing Edges
time limit per test
4 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
You are given an undirected connected graph consisting of nn vertices and mm edges. kk vertices of this graph are special.
You have to direct each edge of this graph or leave it undirected. If you leave the ii-th edge undirected, you pay wiwi coins, and if you direct it, you don't have to pay for it.
Let's call a vertex saturated if it is reachable from each special vertex along the edges of the graph (if an edge is undirected, it can be traversed in both directions). After you direct the edges of the graph (possibly leaving some of them undirected), you receive cici coins for each saturated vertex ii. Thus, your total profit can be calculated as ∑i∈Sci−∑j∈Uwj∑i∈Sci−∑j∈Uwj, where SS is the set of saturated vertices, and UU is the set of edges you leave undirected.
For each vertex ii, calculate the maximum possible profit you can get if you have to make the vertex ii saturated.
Input
The first line contains three integers nn, mm and kk (2≤n≤3⋅1052≤n≤3⋅105, n−1≤m≤min(3⋅105,n(n−1)2)n−1≤m≤min(3⋅105,n(n−1)2), 1≤k≤n1≤k≤n).
The second line contains kk pairwise distinct integers v1v1, v2v2, ..., vkvk (1≤vi≤n1≤vi≤n) — the indices of the special vertices.
The third line contains nn integers c1c1, c2c2, ..., cncn (0≤ci≤1090≤ci≤109).
The fourth line contains mm integers w1w1, w2w2, ..., wmwm (0≤wi≤1090≤wi≤109).
Then mm lines follow, the ii-th line contains two