AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

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 111 and nnn, inclusive.

Hurry will need to start at intersection 111 and run to intersection nnn.

The input is structured as follows:

• One line with three integers: 1≤n≤1051 \leq n \leq 10^51≤n≤105, the number of intersections; 0≤m≤1060 \leq m \leq 10^60≤m≤106, the number of roads; and 1≤s≤n1 \leq s \leq n1≤s≤n, the number of Super Mushrooms.

• One line with max⁡(0,s−2)\max(0, s-2)max(0,s−2) integers: the indices of the intersections that have a Super Mushroom (intersections 111 and nnn will always have a Super Mushroom and are not in this list).

• mmm 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