Requiescat in Pace
InterviewTime limit1sMemory limit1024 MB
Given candidate points and line segments for trails and roads, find the candidate whose distance to the nearest segment is largest.
- Level
Easy3 of 10
- Topics
- Geometry, Brute force
- Solved
- No attempts yet
Problem
After P-22’s death, there was considerable discussion about what should happen to his remains. At first, storing them in the Natural History Museum (across from USC) was proposed. In the end, a native tribe decided to give him a ritualistic burial at an undisclosed location in the Santa Monica Mountains. We do not know exactly how they chose the spot. They probably collected a few candidate locations first, then picked the best one according to one or more criteria. A natural criterion is to be far from all roads and hiking trails, so that the burial site is less likely to be disturbed. P-22 also mostly avoided people while alive. Here, you will choose such a candidate location.
All trails and roads are given as straight line segments. Curved roads can be approximated by a sequence of such segments. You are also given the candidate burial locations. Select the candidate that maximizes the minimum distance to any point on any trail or road.
Input
The first line contains the number of data sets, followed by the data sets, each of the following form.
The first line of each data set contains two integers , the number of trails and the number of candidate locations. Then follow lines, each with two real numbers and , the location of the -th candidate burial site. Then follow lines, each with four real numbers , , , and . The -th trail or road goes straight from to . All coordinates are between and .
Output
For each data set, print “Data Set :” on a line by itself, where is the data set number. Then print the index of the burial site whose distance to its closest point on a trail is largest. Inputs never have ties or near-ties, meaning no two distances to the closest trail differ by less than . Print a blank line after each data set.