#P3393. 逃离僵尸岛
逃离僵尸岛
Description
The country where Xiao A lives has been invaded by zombies! Xiao A plans to escape the country via the only international airport.
The country has cities connected by roads. There are bidirectional roads. There are no self-loops or multiple edges.
Among them, cities have already been taken over by zombies. Entering any such city will result in infection, so these cities cannot be entered. Any city that can be reached from any zombie-controlled city by traversing at most roads is considered dangerous. In other words, if a city’s distance to any zombie-controlled city is at most , then it is dangerous.
Xiao A lives in city , the international airport is in city , and these two cities are not invaded. Xiao A spends an entire day to traverse each single road (moving directly from one city to another), so he must stay at an inn at night. Inns in safe cities are cheaper and cost , while inns in dangerous cities need extra security measures and thus cost . All dangerous cities share the same lodging price, and so do all safe cities. In cities and , no lodging is required.
Xiao A is frugal, so he wants to know the minimum cost to travel from city to city .
The input guarantees that there exists a path and that he can successfully escape.
Input Format
- The first line contains integers .
- The second line contains two integers .
- The next lines each contain one integer , the index of a zombie-controlled city.
- The next lines each contain two integers , indicating an undirected edge.
Output Format
Output a single integer, the minimum total cost.
13 21 1 1
1000 6000
7
1 2
3 7
2 4
5 8
8 9
2 5
3 4
4 7
9 10
10 11
5 9
7 12
3 6
4 5
1 3
11 12
6 7
8 11
6 13
7 8
12 13
11000
Hint

- For of the testdata, .
- For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号