Wesley's Anger Contest 6 Problem 7 - SantaTracker++

View as PDF

Points: 25 (partial)
Time limit: 1.0s
Java 6.0s
Python 6.0s
Memory limit: 256M

Author:
Problem type

Unsatisfied with the usual Santa-tracking tools, Wesley has decided to make one of his own, called SantaTracker++!

Santa's entire trip can be modelled on the Cartesian plane. Santa's sleigh travels at a constant speed from to . In addition, there are rectangular-shaped houses (indexed from to ) of various sizes located on the plane. The house can be modelled as a rectangle of width and height with its bottom left corner located at the coordinates . (Unfortunately due to poor planning, houses may overlap.)

Tracking Santa's movement is too unpredictable, so instead SantaTracker++ needs to predict which house he is currently located at. One known fact about Santa is that he will always deliver gifts to the house that is closest to his sleigh's position on the voyage interval. A house is considered to be closest if there is at least one point on the rectangle closer to the sleigh's current position than any other rectangle in Euclidean distance. In case of a tie in distance the house with the smaller index will be considered closer (these houses are more likely to house well-behaved kids).

For undisclosed reasons, Wesley needs to know which houses will Santa most likely end up at any point in the journey. For every house, find the percentage of Santa's trajectory where Santa's sleigh is closest to that house. As the lead developer of SantaTracker++, please help him out!

Constraints

For this problem, you will NOT be required to pass all the samples to receive points, and you are NOT required to pass all previous subtasks to receive points for a specific subtask.

Input Specification

The first line will contain two integers and , the number of houses and the length of the sleigh's trajectory.

The next lines describe the houses on the Cartesian plane. Each line will contain integers , , , , indicating the coordinates of the bottom left corner, the width, and the height of the rectangle respectively.

Output Specification

This problem is graded with a custom checker.

Output lines, with the line describing the percentage of the sleigh's trajectory where the house is closest. Ensure that every line is terminated with a \n character and has no leading nor trailing spaces.

Your answer will be considered correct if it has an absolute or relative error of at most from the reference solution. It is guaranteed that the absolute or relative error of the reference solution is much smaller than from the optimal solution.

Sample Input 1

2 10
1 2 5 1
2 1 1 5

Sample Output 1

52.679491924
47.320508076

Sample Explanation 1

The sleigh will be closest to the first house for of its journey and closest to the second house for the other .

Sample Input 2

4 7
1 3 0 0
3 4 0 0
5 5 0 0
3 4 0 0

Sample Output 2

53.571428571
35.714285714
10.714285714
0.000000000