AirlineInternet
SRM 393 · 2008-03-11 · by StevieT
Problem Statement
An airline wishes to supply passengers with Internet access on its flights. To do so, it is going to to install powerful radio transceivers on all of its aircraft and at the airports it operates from. The airports will be connected to the Internet and the aircraft will be able to access the connection via a radio link to any airport that is within the range of its tranceiver. Aircraft will also be able to relay the Internet connection on to other aircraft that are within range, so even if an aircraft cannot communicate directly with an airport, it may be able to access the Internet via another aircraft. The cost of the radio equipment is proportional to its range and the airline wishes to supply the Internet connection at minimal cost. It therefore wants your help in determining the minimum transceiver range required such that all of the aircraft can access the Internet all of the time.
The area that the airline operates in is represented as a 2-D cartesian plane. You are given a
Notes
- Your return value must be accurate to within an absolute or relative tolerance of 1E-9.
Constraints
- airportLocations will contain between 2 and 10 elements, inclusive.
- Each element of airportLocations will contain 2 space-separated integers, formatted without leading zeros, between 0 and 1000, inclusive.
- The elements of airportLocations will be distinct.
- flights will contain between 1 and 20 elements, inclusive.
- Each element of flights will be formatted "<start> <destination> <take-off time> <landing time>" (quotes for clarity).
- <start> and <destination> will be integers, formatted without leading zeros, between 0 and N-1, inclusive, where N is the number of elements in airportLocations.
- <take-off time> and <landing time> will be integers, formatted without leading zeros, between 0 and 1000, inclusive.
- In each element of flights, <start> and <destination> will be distinct and <take-off time> will be strictly less than <landing time>.
{"0 0","100 0"}
{"0 1 0 100"}
Returns: 50.0
A single aircraft flies between two airports. It is farthest from an airport when it is exactly halfway between them, so the minimum required range is half the distance between the two airports.
{"0 0","100 0"}
{"0 1 0 100","0 1 25 125","0 1 50 150","0 1 75 175"}
Returns: 25.0
This time, four aircraft fly between the same two airports, setting off at intervals of 25 time units. The aircraft closer to the airports can relay the connection to those farther away, so the minimum required range is shorter.
{"25 100","0 50","90 150","22 22","60 1","95 8","12 40"}
{"0 1 0 500","2 5 10 300","2 0 100 200"
,"3 6 150 400","4 5 50 450","5 1 0 300"
,"2 6 10 100"}
Returns: 64.28201130009927
{"0 0","50 0","100 0"}
{"0 1 0 100"}
Returns: 25.0
All airports have radio transceivers, even if no aircraft fly to or from them.
{"0 0","100 0"}
{"0 1 0 100","0 1 10 110","0 1 20 120","0 1 30 130","0 1 40 140"}
Returns: 30.0
Submissions are judged against all 54 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AirlineInternet with a public method double minimumRange(vector<string> airportLocations, vector<string> flights) · 54 test cases · 2 s / 256 MB per case