Bombs
Time limit3sMemory limit1024 MB
Given a multigraph with room 0 as the outside, find the fewest days to route k labeled bombs to their target rooms when each door and each bomb allows one crossing per day.
- Level
Hard8 of 10
- Topics
- Graph, BFS, Shortest path, Bit manipulation
- Solved
- No attempts yet
Problem
Your team has discovered that the fearsome Bureau of Global Overlords (BGO) has devised a plan for world domination. The only way to save the world from certain doom is to blow up the BGO headquarters.
You have bombs at your disposal, and an expert has analysed the headquarters' super-intricate floor plan and pointed out the best rooms to place them. The last remaining problem is that the BGO headquarters has a somewhat peculiar surveillance system in their doors; the bombs are just a tiny tad below the threshold for the amount of suspiciousness the door surveillance accepts per day. Hence, each day only a single bomb may pass a given door in the headquarters. Moreover, the surveillance system is based on a type of ultrafancy wave technology that makes the bomb feel quite unwell, so it is only safe to carry a particular bomb through a single door each day as well.
Assuming your stealth skills grant you unlimited access, how many days are required to place the bombs?
Input
The first line contains three space-separated integers, , and . The first integer denotes the number of rooms in the BGO headquarters; the rooms are labelled with numbers from to (inclusive). For simplicity we denote the outside (where all the bombs are initially) as room .
The second integer denotes the number of doors between rooms in the headquarters. Note that there may be multiple doors between the same rooms, and that some doors may go to the outside. The third integer denotes the number of bombs.
On the second line follows space-separated integers , indicating the rooms where the bombs should be placed ( for every ).
Finally follows lines, each describing a door. Each such line contains two distinct space-separated integers indicating that there is a door between room and room .
Output
Output a single integer, the minimum number of days required to place the bombs.