#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 cities (numbered from to ). These cities are connected by undirected roads, and each road has its own length (all greater than ).
There are affected cities. The government of Country T plans to send one rescue team from the capital (City ) to each of these 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 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 , with meanings as described above. It is guaranteed that , , and .
The second line contains integers, each being or , indicating in order whether the corresponding city can build a supply point ( means it can).
The third line contains positive integers , representing the indices of the affected cities. It is guaranteed that these numbers are all distinct and the capital is not affected, and .
The next lines each contain three integers , indicating that there is a road of length between City and City , where and .
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 is the capital and nodes are affected cities:

For this sample, at least supply points are needed. They can be built at or at . Note that they cannot be built at nodes , because the only shortest path from the capital to node is , and there is no shortest path that passes through nodes .
Subtasks
| Test Point | Special Property | |||
|---|---|---|---|---|
| The input is a tree. | ||||
| None. | ||||
Translated by ChatGPT 5