eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Shortest Flight Path

Shortest Flight Path

Commercial flights are statistically quite safe (in terms of number of deaths per passenger-kilometer, only going to the moon is safer). But there are still reasons for precautions and safety regulations. An early such rule was the so-called "\textbf{60}-minute rule," which required that a two-engine plane must always be within \textbf{60} minutes of the nearest adequate airport along its entire flight path. A variety of similar rules have existed, but at their core, they remain the same: the flight path can not take the airplane more than a certain maximum allowed distance from the nearest airport. With these restrictions, planes cannot always use a direct route for flying from one airport to another. In this problem we will compute the shortest flight path between two airports while adhering to a maximum allowed distance rule. In the figure below, which illustrates the first sample test case, any flight route has to stay within the three circles. Thus a plane going from airport \textbf{2} to airport \textbf{3} has to detour from the direct route via the region around airport \textbf{1}. Note that the plane would not necessarily have to go to airport \textbf{1} itself. \includegraphics{https://static.e-olymp.com/content/b1/b138d15c72561fa4c7b4da5c6b3cb51beac153e9.jpg} Things are further complicated by the fact that planes have limited fuel supply, and to go longer distances they may need to make a stopover at intermediate airports. Thus, depending on the fuel capacity, a plane going from airport \textbf{2} to airport \textbf{3} in the figure might have to stop over at airport \textbf{1} (or the fuel capacity might be too low even to go to airport \textbf{1}, in which case the trip would be impossible to make). We make the following simplifying assumptions: \begin{enumerate} \item The surface of the earth is a sphere of radius \textbf{6370} km. \item Both time and fuel consumption are directly proportional to distance traveled. In other words weare interested only in total distance traveled. \item The difference in distance caused by planes flying at different altitudes is negligible. Thus, effectively, we assume them to be flying along the earth’s surface. \item A plane may stop for refueling at as many intermediate airports as needed, each time getting a fulltank. \end{enumerate} \InputFile The first line of each test case contains two integers \textbf{N} and \textbf{R}, where \textbf{2} ≤ \textbf{N} ≤ \textbf{25} is the number of airports and \textbf{1} ≤ \textbf{R} ≤ \textbf{10000} is the maximum allowed flight distance (in km) from the nearest airport. Each of the next \textbf{N} lines contains two integers \textbf{φ}, \textbf{θ} satisfying \textbf{0} ≤ \textbf{φ} < \textbf{360} and \textbf{-90} ≤ \textbf{θ} ≤ \textbf{90}, the longitude and latitude (respectively) of an airport, in degrees. The airports are numbered according to their order in the input starting from one. No two airports are at the same position. Following this is a line containing an integer \textbf{Q}, satisfying \textbf{1} ≤ \textbf{Q} ≤ \textbf{100}. Each of the next \textbf{Q} lines contains three integers \textbf{s}, \textbf{t}, \textbf{c} satisfying \textbf{1} ≤ \textbf{s}, \textbf{t} ≤ \textbf{N}, \textbf{s} ≠ \textbf{t}, and \textbf{1} ≤ \textbf{c} ≤ \textbf{50000}, indicating a plane going from airport \textbf{s} to airport \textbf{t} with a fuel capacity yielding a range of \textbf{c} km. \OutputFile For each test case, display the case number followed by one line for each query containing the length in km of the shortest flight path between airport \textbf{s} and \textbf{t}, subject to the fuel constraint \textbf{c}. Display the length accurate to three decimal places. If there is no permissible path between the two airports, then display the word \textbf{impossible} instead. You may assume the answer is numerically stable for perturbations of up to \textbf{0.1} km of \textbf{R} or \textbf{c}.
Лимит времени 3 секунды
Лимит использования памяти 256 MiB
Входные данные #1
3 2000
0 0
0 30
30 0
3
2 3 5000
2 3 4000
2 3 3000
2 10000
45 45
225 -45
2
1 2 50000
2 1 50000
Выходные данные #1
Case 1:
4724.686
6670.648
impossible
Case 2:
impossible
impossible
Источник ACM-ICPC World Finals 2012