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

The Flight Way

The Flight Way

Club of obsolete vehicles decided to celebrate the May \textbf{5}th, \textbf{5555} with great flights of copies of ancient air planes. Club members have built in various places on the Earth surface \textbf{N} (\textbf{2} ≤ \textbf{N} ≤ \textbf{1000}) aerodromes and prepared planes. But suddenly an amendment to the ecological taxes law was adopted, so the club must hold the celebrations in short format. Two aerodromes were selected, and the only one plane will fly between them using the shortest possible way! The maximum distance it can fly without landings is \textbf{R} km, so if necessary it can use intermediate aerodromes. Help the club to find the shortest route, considering the Earth surface accurate sphere with equator length exactly \textbf{40000} km and ignoring the influence of flying height at the distance. \InputFile The first row of the input contains \textbf{R} -- the maximum direct fly distance (in kilometers, \textbf{10} ≤ \textbf{R} ≤ \textbf{50000}). The second row contains the number of aerodromes \textbf{N}. The following \textbf{N} rows contain geographic coordinates of the aerodromes. The format of coordinates is: first the latitude (uppercase letter \textbf{N} or \textbf{S} --- North or South, then degrees, minutes and seconds), then longitude (similarly, but using the letter \textbf{E} or \textbf{W} --- East or West), all numbers and letters are separated by single space. Degrees and minutes are integers, seconds can have decimal fractions. At the last line of the input, two integers denotes the aerodromes selected as start and finish (\textbf{1}-based, i. e. numeration starts from \textbf{1}). \OutputFile Your program should output three lines. The \textbf{1}st line should contain one floating-point value --- the minimal possible length of route from start to finish, in kilometers, with accuracy up to meters. The \textbf{2}nd line should contain exactly one integer \textbf{K} --- the number of intermediate aerodromes in the route. The \textbf{3}rd line should contain list of these intermediate aerodromes, in order from start to finish. If there are different correct answers, your program should find any one of them. If plane can reach finish from start without landings, the \textbf{2}nd line should contain \textbf{0} and the \textbf{3}rd line should be empty. If plane cannot reach finish from start, the \textbf{1}st line must contain number \textbf{123456789.000}, the \textbf{2}^nd --- number \textbf{0} and the \textbf{3}rd should be empty
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
7127
5
N 90 0 0 E 0 0 0
N 0 0 0 W 15 0 0
S 90 0 0 E 0 0 0
N 30 0 0 E 175 0 0
S 30 0 0 W 175 0 0
1 3
Выходные данные #1
20083.446
2
4 5
Источник International Collegiate Programming Contest, Ukraine, Quarter-Final,May 19, 2011