#P10339. [THUSC 2019] 补给计划

[THUSC 2019] 补给计划

Background

Country T is a small country. Due to a once-in-a-century cold wave, some cities have been severely affected. The government of Country T plans to send rescue teams from the capital to help the affected cities, and at the same time build several supply points to support the rescue teams.

Problem Description

Country T has a total of NN cities (numbered from 11 to NN). These cities are connected by MM undirected roads, and each road has its own length (all greater than 00).

There are KK affected cities. The government of Country T plans to send one rescue team from the capital (City 11) to each of these KK cities. To better complete the rescue operations, the government also plans to build supply points in some cities.

However, due to factors such as geography and funding, not every city can build a supply point (whether a city can build a supply point is unrelated to whether it is the capital or an affected city).

To finish the rescue as soon as possible, each of the KK rescue teams will travel to its destination only along shortest paths. The government wants to build as few supply points as possible among the cities where supply points can be built, so that for every rescue team, at least one shortest path to its destination passes through at least one supply point.

You are given the information of the cities and roads in Country T. You need to compute the minimum number of supply points the government must build.

Input Format

The first line contains three integers N,M,KN, M, K, with meanings as described above. It is guaranteed that 1N2001 \le N \le 200, 0M100000 \le M \le 10000, and 1K201 \le K \le 20.

The second line contains NN integers, each being 00 or 11, indicating in order whether the corresponding city can build a supply point (11 means it can).

The third line contains KK positive integers xix_i, representing the indices of the affected cities. It is guaranteed that these KK numbers are all distinct and the capital is not affected, and 1xiN1 \le x_i \le N.

The next MM lines each contain three integers u,v,wu, v, w, indicating that there is a road of length ww between City uu and City vv, where 1u,vN1 \le u, v \le N and 0<w1090 < w \le 10^9.

The input guarantees that there exists at least one solution that satisfies the requirements in the statement.

Output Format

Output one integer, the answer.

6 6 3
0 1 1 1 1 1
3 4 6
1 2 2
2 3 3
2 4 4
1 5 3
5 4 4
5 6 3

2

7 6 3
0 1 1 1 1 1 1
3 4 6
1 2 1
2 4 1
2 5 1
5 6 5
1 3 2
1 7 5

2

Hint

Sample Explanation 1

The graph corresponding to this sample is shown below, where node 11 is the capital and nodes 3,4,63, 4, 6 are affected cities:

For this sample, at least 22 supply points are needed. They can be built at 2,52, 5 or at 2,62, 6. Note that they cannot be built at nodes 3,53, 5, because the only shortest path from the capital to node 44 is 1241 \rightarrow 2 \rightarrow 4, and there is no shortest path that passes through nodes 3,53, 5.

Subtasks

Test Point NN MM KK Special Property
121\cdots 2 1N2001 \le N \le 200 M=N1M = N - 1 1K201 \le K \le 20 The input is a tree.
363\cdots 6 0M100000 \le M \le 10000 1K41 \le K \le 4 None.
7127\cdots 12 1K161 \le K \le 16
132013\cdots 20 1K201 \le K \le 20

Translated by ChatGPT 5