Let There Be Light
Time limit5sMemory limit128 MB
Given up to 2000 balloons blocking up to 15 point lights from a target point, choose at most R balloons to remove to maximize total illumination, computed via geometric occlusion and a min-cut/greedy set-cover style optimization over light-blocking sets, printed as an exact fraction.
- Level
Medium7 of 10
- Topics
- Geometry, Bit manipulation, Combinatorics, Brute force
- Solved
- No attempts yet
Problem
Suppose there are some light sources and many spherical balloons. Every light source is small enough to be modeled as a point light source, and it emits light in all directions. The surfaces of the balloons absorb light and do not reflect it. Surprisingly, in this world balloons may overlap.
You want the total illumination intensity at an objective point to be as high as possible. To achieve this, some of the balloons that obstruct light can be removed. Because of removal costs, however, there is a limit on the number of balloons that may be removed. You would like to remove an appropriate set of balloons so as to maximize the illumination intensity at the objective point.
Input
The input is a sequence of datasets. Each dataset is formatted as follows.
N M R
S1x S1y S1z S1r
...
SNx SNy SNz SNr
T1x T1y T1z T1b
...
TMx TMy TMz TMb
Ex Ey Ez
The first line of a dataset contains three positive integers , and , separated by a single space. is the number of balloons and does not exceed . is the number of light sources and does not exceed . is the number of balloons that may be removed, which does not exceed .
Each of the following lines contains four integers separated by a single space. is the center of the -th balloon and is its radius.
Each of the following lines contains four integers separated by a single space. is the position of the -th light source and is its brightness.
The last line of a dataset contains three integers separated by a single space. is the position of the objective point.
, , , , , , , and are greater than and less than . is greater than and less than . is greater than and less than .
At the objective point, the intensity of the light from the -th light source, if no balloon interrupts it, is inversely proportional to the square of the distance, namely
The total illumination intensity is the sum of these contributions over the light sources that reach the objective point.
You may assume the following.
- The distance between the objective point and any light source is at least .
- For every and , even if changes by (with ), whether the -th balloon hides the -th light source or not does not change.
The end of the input is indicated by a line of three zeros.
Output
For each dataset, output on its own line the maximum possible total illumination intensity at the objective point after removing at most balloons.
Because every coordinate, radius, and brightness is an integer, each light source that reaches the objective point contributes an intensity of the form with an integer , so the maximum total intensity is always a rational number. Print it as an exact reduced fraction p/q, where q is a positive integer, p is a non-negative integer, and . When the maximum intensity is , print 0/1.