Growing Some Oobleck
Time limit1sMemory limit1024 MB
Given circles that grow at fixed rates, find the center and radius of the single circle formed after all touching circles merge in chain reactions.
- Level
Medium6 of 10
- Topics
- Simulation, Geometry, Implementation
- Solved
- No attempts yet
Statement
Oobleck is a fascinating magical substance. Leave it in sunlight and it grows in an ever-expanding circle. If two circles ever touch, both circles merge into one combined circle. The area of the combined circle equals the total area of both circles, and its center is at the midpoint of the two original centers. The expansion rate of the new circle is the larger of the rates of the two colliding circles. See Figures F.1 and F.2 for an example.

Figure F.1: Circle A has center , radius and area . Circle B has center , radius and area .

Figure F.2: After they merge, they are replaced by circle C with center , radius and area .
After a new circle is created, it may intersect other existing circles, causing a chain reaction of merges. This combination of an intersection followed by one or more merges is called an ooblection. An ooblection occurs instantaneously at the moment of the first intersection, even though it may contain a cascade of merges. When three or more circles are involved in a merge, the resulting circle has its center at the average of the centers of all circles involved, and its area is the sum of their areas. The expansion rate of the final circle after an ooblection is the maximum rate of any circle involved.

Figure F.3: A five-circle ooblection.
Figure F.3 shows a five-circle ooblection, described in the second sample. At time the circles have expanded to the state in Figure F.3a. At that time circles A and B merge into circle F (Figure F.3b). Circle F intersects circles C and D and merges with them into circle G (Figure F.3c). Finally, circle G intersects circle E and produces the final circle H (Figure F.3d). All of this happens at time . The expansion rate of circle H is the maximum expansion rate of circles A through E. With the values in Sample Input 2, this maximum is 2.
As any set of circles grows, they will eventually ooblect into a single circle. Your task is to find the position and area of that circle at the moment it is created.
Input
The first line contains a positive integer (), the number of circles. The next lines each contain four numbers , , and . and () give the center of the circle. () is the initial radius. () is the expansion rate. No two circles in the input are touching. At most one ooblection begins at any given moment, and each ooblection starts with the touching of exactly two circles.
Output
Output two lines. The first line contains two numbers and , the center of the final circle at the moment it is created. The second line contains the radius of that circle. Answers are accepted with a relative or absolute error of .