Biking Duck
Time limit2sMemory limit256 MB
Find the shortest travel time between two map points, walking anywhere but biking only between stations, with free station placement off the map.
- Level
Medium7 of 10
- Topics
- Shortest path, Geometry, Math
- Solved
- No attempts yet
Problem
Gladstone Gander is walking through Duckburg and has to reach his date with Daisy Duck as fast as he can. If he arrives late, Donald may show up and take his place.
Duckburg recently started a free public bike program. At bike stations all over the city you take a bike, ride it to another bike station, and leave it there. So Gladstone travels in two ways: he walks, or he bikes. Biking is faster, but he takes a bike only at a station and leaves it only at a station. Walking or biking, he moves in a straight line between any two points.
Gladstone carries a map of the rectangular center of Duckburg. His current position and the meeting point with Daisy are both on this map, and the map marks every bike station inside its borders.
More bike stations exist outside the map. Gladstone has endless luck, so you may assume that the moment he walks or rides off the map, a station happens to be exactly where it suits him. Stations outside the map lie anywhere outside it, and their coordinates need not be integers.
Given the map, compute the shortest time Gladstone needs to reach Daisy.
Input
The input consists of:
- one line with two integers and (), the walking speed and the biking speed;
- one line with four integers , , , (; ), the bounding coordinates of the map of the center;
- one line with two integers and , Gladstone's position;
- one line with two integers and , Daisy's position;
- one line with one integer (), the number of bike stations marked on the map;
- lines with two integers and each, the coordinates of one marked station.
Every given coordinate lies on the map, that is and .
Output
Print one line with the shortest time Gladstone needs to reach Daisy, rounded to six digits after the decimal point. Print all six digits.