Great Circle
Time limit1sMemory limit128 MB
Given latitude and longitude of two cities in degrees and minutes, find the most northerly latitude on the great circle arc between them, or print undefined if it is not unique.
- Level
Hard8 of 10
- Topics
- Geometry, Math, Implementation, Simulation
- Solved
- No attempts yet
Problem
Airplanes fly close to the Great Circle route between two cities. The Great Circle route is the shortest arc, concentric with the Earth, that joins the two cities — that is, the shortest distance between the two cities along the surface of the Earth.
Given the latitude and longitude of two cities, find the most northerly latitude reached along the Great Circle route between them. If there is no unique answer, print undefined.
Input
The first line contains an integer , the number of test cases. Each of the next lines describes one case as four whitespace-separated tokens — lat1 lon1 lat2 lon2 — giving the latitude and longitude of the two cities in degrees, minutes, and direction.
A latitude token has the form degrees,minutesD, where D is N or S; a longitude token has the form degrees,minutesD, where D is E or W. One minute equals of a degree.
By convention, points on the equator have latitude 0,0N (not 0,0S); points on the poles have longitude 0,0W; and points at 180 degrees of longitude are written 180,0W (not 180,0E).
Output
For each test case, print a single line with the most northerly latitude reached, written in the same degrees,minutesD format and rounded to the nearest minute. Print undefined if there is no unique answer.