Editorial for Bubble Cup V8 E Spectator Riots
Submitting an official solution before solving the problem yourself is a bannable offence.
First we simplify the problem by replacing the initial set of points with the set of all points where some fan might appear after one second, call that set . Every point in has a probability that a specific player will appear there. Consequently, for every point in we know the expected number of fans at it after one second, call it .
Now, for some arbitrary circle that passes through some three points of (which doesn't violate the rules of the problem), the expected number of fans caught on camera is the sum of all , where is a point on or inside the circle. Our goal is to find a circle that maximizes that sum.
After drawing a few examples, we can notice that we can always catch most of the points that are possible locations of some fan or even all of them. We can write a brute-force solution that will increase our suspicion that all fans can be caught, no matter how they move.
Now let's try to find the largest circle of those that surely catches all fans and doesn't violate the rules in the problem. It is easy to see that three fixed points that determine the circle must lie on the convex hull of (otherwise we surely wouldn't catch all points of with that circle).
Convex hull can be computed in , which might be too slow if unnecessary points are not eliminated from .
Notice that for every fan in input, if his speed is , he might appear at points, so convex hull algorithm would have complexity, which is too slow.
The trick is to take only the convex hull of those points, which will have points. All other points should be eliminated from as they don't have a chance of appearing on the convex hull of . Contestants need to be careful with edge cases when a fan potentially goes out of the field.
After computing the convex hull of (call it ), we hope to find the circle that will pass through some three points on that hull and contain all other points inside it or on it.
These two claims can be proven geometrically:
- For a convex polygon, the largest circle among all circumcircles of triangles determined by the polygon vertices will surely contain all vertices of the polygon on it or inside it.
- For a convex polygon, the largest circumcircle of some triangle that is determined by vertices of the polygon is a circumcircle of a triangle that contains three consecutive vertices of a polygon.
With 1 and 2 we conclude:
The largest circle among those that are circumscribed around triangles that are composed of three consecutive vertices of contains all of the points of (and then obviously of ) and no other circle that contains all those points can be larger.
This means that we can finish the problem easily in linear time (with respect to the size of the convex hull).
Comments