Hurry the Hedgehog
시간 제한5초메모리 제한2048 MB
무향 그래프에서 1번에서 n번까지 이동할 때 지나는 모든 교차점에 Super Mushroom이 있도록 하는 최단 경로의 교차점 수를 구한다.
문제
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?
입력
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.
출력
One line containing one integer, which is the number of intersections in the path that Hurry will have to run.