Quadcopter
To bolster the nation's defense capabilities and enhance aerial reconnaissance, drones are being increasingly utilized.
A drone is an unmanned aerial vehicle that travels between designated points on the terrain. Its flight range is limited by its battery capacity.
The coordinates of these points, between which the drone can travel, are known. Additionally, it is specified at which points the drone can recharge.
What is the minimum distance the drone must fly (recharging at necessary points) to travel from point A to point B? It is given that the drone starts with a fully charged battery at point A.
Input data.
The first line contains five numbers:
( N ) – the number of points (1 ≤ ( N ) ≤ 1,000),
( K ) – the number of points where the drone can recharge (1 ≤ ( K ) ≤ ( N )),
( R ) – the maximum distance the drone can fly on a full charge (real number),
( A ) – the starting point for the drone (1 ≤ ( A ) ≤ ( N )),
( B ) – the destination point for the drone (1 ≤ ( B ) ≤ ( N )).
The next ( N ) lines each contain two numbers representing the X and Y coordinates of the points. The following line contains ( K ) numbers separated by spaces, indicating the points where the drone can recharge.
Output data.
A real number representing the minimum distance the drone must fly to reach from point A to point B, or -1 if the journey is not possible.
Examples
Note
Consider there are 4 points in total, with 1 point available for recharging the drone's battery. The maximum distance the drone can fly without recharging is 5. The drone starts from point 1 and needs to reach point 4. The coordinates of the points are: 1 (-3, 3), 2 (-3, -2), 3 (2, 2), 4 (2, -2). Point 3 is the one where recharging is possible.
The drone starts at point 1, flies to point 3, covering a distance of 5.0, recharges, and then flies to the final point 4 (distance – 4.0). Thus, the total distance is 9.0.