Cleaning the Hallway
Time limit5sMemory limit128 MB
Given up to 500 outlets, each cleaning the ring swept by a small disk around a circle, compute the area of their union rounded to two decimals.
Problem
people clean the floor with vacuum cleaners. It looks like they can clean the whole floor, but they cannot. A cleaner runs only while it is plugged into an outlet in the floor, and the wire has a fixed length.
If the wire of a cleaner is long, the person using that cleaner can move at most away from the outlet. The wire is faulty, so the moment it goes even slightly loose, meaning the person comes closer than to the outlet, the cleaner loses power. The person can therefore stand only at distance exactly from the outlet. The handle is heavy as well, so the person cannot push the cleaner head farther than from where they stand.
In short, one cleaner cleans every point of the floor at distance or less from a person standing at distance exactly from the outlet.
For each cleaner you are given , , and the coordinate of the outlet it is plugged into. Find the area of the floor that can be cleaned with this arrangement. Several people may clean the same spot, so the answer is the area of the union, not the sum of the areas each of them cleans.
Input
The first line has the number of test cases . ()
Each test case has the following form.
- The first line has the number of cleaners . ()
- Each of the next lines has four integers , , , separated by one space, describing one cleaner. is the coordinate of the outlet, is the wire length, and is the distance between the person and the cleaner head. (, )
Output
For each test case print one line in the form Case x: A. Here is the test case number starting from 1, and is the cleanable area rounded to two decimal places.
The exact area always differs by more than from every value of the form ( an integer), so the rounded value is determined uniquely.
Hint
The first test case has a single cleaner. The outlet sits at with and , so the person walks along the circle of radius 10 centered at . The cleaner reaches every point at distance 1 or less from the person, so the cleaned region is the ring between the two circles centered at with radii 9 and 11. Its area is , printed as 125.66.
The second test case has two cleaners. The first one is plugged into the outlet at and cleans the ring between radii 6 and 8. The second one is plugged into the outlet at and cleans the ring between radii 9 and 11. The two rings overlap, so the area of the union is smaller than the sum of the two ring areas.