FPC19-013.Hurry the Hedgehog
Easy · 1 s · 256 MB
- icpc
- fpc
- 2019
Hurry is a Hedgehog, who lives in the Mushroom Kingdom. He is on a mission to save Princess Plum from the evil Donkey Kong. In order to get to the Princess, Hurry must run through a hyperspace network of roads. These roads are dangerous and for every road that he walks between two intersections, he is getting attacked by Space Invaders. Luckily, at some intersections, there is a Super Mushroom that will restore Hurry's health.
Can you find the shortest path through the network of roads, such that you can eat a Super Mushroom at each intersection?
Giriş formatı
The intersections are numbered between and , inclusive.
Hurry will need to start at intersection and run to intersection .
The input is structured as follows:
• One line with three integers: , the number of intersections; , the number of roads; and , the number of Super Mushrooms.
• One line with integers: the indices of the intersections that have a Super Mushroom (intersections and will always have a Super Mushroom and are not in this list).
• lines with two integers each, indicating that there is a road between the two intersections with these indices.
Çıxış formatı
One line containing one integer, which is the number of intersections in the path that Hurry will have to run.
Qeyd
Source: Freshmen Programming Contest 2019 · License: CC BY-SA 4.0 · Original: https://fpc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 2 of the 10 original test cases (the largest) are omitted here to keep the problem lightweight.
Nümunələr
Giriş #1
6 6 5 3 4 5 1 2 2 6 1 3 3 4 4 5 5 6
Çıxış #1
5
Giriş #2
6 6 6 2 3 4 5 1 2 2 6 1 3 3 4 4 5 5 6
Çıxış #2
3