Wish upon a shooting star
Time limit8sMemory limit512 MB
Given moving spheres whose radii shrink linearly, find the vanish time of each, where touching pairs annihilate each other, in order.
- Level
Hard8 of 10
- Topics
- Simulation, Geometry, Math, Sorting
- Solved
- No attempts yet
Problem
The mysterious organization JAG (Japanese Alumni Group) holds meetings on a regular basis. One day the topic was "how to enable the participating teams to perform at their best in the upcoming ICPC (International Collegiate Programming Contest) domestic preliminary round." The conclusion of the meeting was to wish each team good luck upon shooting stars, and they went up to the roof of the building that houses their headquarters.
When they reached the roof, shooting stars were visible in the sky. A shooting star is represented as a sphere in three-dimensional space, and the stars are numbered through . A member knowledgeable about stars determined that each shooting star can be regarded as moving in a straight line at a constant speed while its radius shrinks at a constant rate. Actual measurements gave the initial position , the velocity , the initial radius , and the shrink rate of each shooting star. This means that at time () shooting star is a sphere with center and radius . A shooting star vanishes on its own the moment its radius becomes 0. Also, if two shooting stars touch, both of them vanish.
Your job is to determine, so that they can wish the participating teams good luck efficiently, the time until each shooting star vanishes. Since some of them have outstanding eyesight, you do not need to consider the possibility of shooting stars other than the given . In addition, they observed the shooting stars very efficiently, so you may consider the time spent observing to be negligibly small.
Input
The input consists of multiple datasets, and the number of datasets in one input is at most 100. The format of each dataset is as follows.
...
is an integer representing the number of shooting stars, and you may assume .
The following lines give the information about the shooting stars. Each line contains 8 values with 4 digits after the decimal point, where is the initial position of shooting star , is its velocity, is its initial radius, and is its shrink rate. For the given values you may assume , , , , , , , and .
For each given dataset you may also assume the following.
- Even if the initial radius of one shooting star changes by , the set of pairs of stars that touch does not change.
- Even if one shooting star is assumed not to vanish by touching, it does not touch two or more shooting stars within of time, nor does it vanish on its own within of the time it touches another shooting star.
- In the initial state no two shooting stars overlap, and they are at least apart.
- At time , no two shooting stars touch.
marks the end of the input. It is not included in the datasets.
Output
For each dataset, output the time until each shooting star vanishes, one per line, in order starting from shooting star 1.
The output must not have an absolute error greater than .
Do not output any other extra characters.