QOJ.ac

QOJ

Límite de tiempo: 10 s Límite de memoria: 256 MB Puntuación total: 100

#23849. Zombie Island

Estadísticas

The island where JOI-kun lives has been invaded by zombies. JOI-kun has decided to flee to the shelter designated as the safest evacuation site on the island.

The island where JOI-kun lives consists of $N$ towns numbered from Town $1$ to Town $N$, and the towns are connected by roads. There are $M$ roads on the island, and every road connects $2$ different towns. JOI-kun can move freely in both directions along the roads, but he cannot travel from one town to another except via roads.

Several towns are controlled by zombies and cannot be visited. A town that can be reached from a zombie-controlled town using $S$ or fewer roads is called a dangerous town. Any other town is called a non-dangerous town.

JOI-kun's house is in Town $1$, and the evacuation shelter is in Town $N$. Town $1$ and Town $N$ are not controlled by zombies. Since it takes a long time to travel along the roads of the island, every time JOI-kun moves to a town, he must stay overnight in the destination town. When JOI-kun stays overnight in a non-dangerous town, he stays at a cheap inn whose accommodation fee is $P$ yen, whereas when he stays overnight in a dangerous town, he stays at a luxury inn with excellent security service whose accommodation fee is $Q$ yen. JOI-kun wants to travel so that his accommodation cost is as cheap as possible and evacuate to Town $N$. He does not need to stay overnight in Town $1$ or Town $N$.

Find the minimum possible total accommodation fee required when JOI-kun travels from Town $1$ to Town $N$.

Input

The input consists of $2 + K + M$ lines.

The $1$-st line contains $4$ space-separated integers $N, M, K, S$ ($2 \le N \le 100000$, $1 \le M \le 200000$, $0 \le K \le N - 2$, $0 \le S \le 100000$). This indicates that the island consists of $N$ towns and $M$ roads, $K$ of the $N$ towns are controlled by zombies, and towns reachable from a zombie-controlled town using $S$ or fewer roads are called dangerous towns.

The $2$-nd line contains $2$ space-separated integers $P, Q$ ($1 \le P < Q \le 100000$). This indicates that JOI-kun stays at an inn costing $P$ yen in a non-dangerous town and at an inn costing $Q$ yen in a dangerous town.

The $i$-th line ($1 \le i \le K$) of the following $K$ lines contains an integer $C_i$ ($2 \le C_i \le N - 1$). This indicates that Town $C_i$ is controlled by zombies. $C_1, \dots, C_K$ are all distinct.

The $j$-th line ($1 \le j \le M$) of the following $M$ lines contains $2$ space-separated integers $A_j, B_j$ ($1 \le A_j < B_j \le N$). This indicates that there is a road between Town $A_j$ and Town $B_j$. The same pair $(A_j, B_j)$ does not appear $2$ or more times.

In the given input data, it is guaranteed that it is possible to travel from Town $1$ to Town $N$ passing only through towns not controlled by zombies.

Output

Output in $1$ line the minimum possible total accommodation fee required when JOI-kun travels from Town $1$ to Town $N$.

Note that the output may not fit within the range of a $32$-bit signed integer.

Examples

Input 1

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

Output 1

11000

Note 1

Sample $1$ corresponds to the figure below. Circles represent towns and lines represent roads.

problem_23849_bac2d8f5a931b2ef74845a3e75798198.png

In this case, Town $3$, Town $4$, Town $6$, Town $8$, and Town $12$ are dangerous towns.

By moving through towns in the following order, the total accommodation fee can be minimized:

  • Go from Town $1$ to Town $2$. Stay at a cheap inn costing $1000$ yen in Town $2$.
  • Go from Town $2$ to Town $5$. Stay at a cheap inn costing $1000$ yen in Town $5$.
  • Go from Town $5$ to Town $9$. Stay at a cheap inn costing $1000$ yen in Town $9$.
  • Go from Town $9$ to Town $10$. Stay at a cheap inn costing $1000$ yen in Town $10$.
  • Go from Town $10$ to Town $11$. Stay at a cheap inn costing $1000$ yen in Town $11$.
  • Go from Town $11$ to Town $12$. Stay at a luxury inn costing $6000$ yen in Town $12$.
  • Go from Town $12$ to Town $13$. Do not stay overnight in Town $13$.

When JOI-kun travels along this route, the total accommodation fee is $11000$ yen, so output $11000$.

Input 2

21 26 2 2
1000 2000
5
16
1 2
1 3
1 10
2 5
3 4
4 6
5 8
6 7
7 9
8 10
9 10
9 11
11 13
12 13
12 15
13 14
13 16
14 17
15 16
15 18
16 17
16 19
17 20
18 19
19 20
19 21

Output 2

15000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.