Editorial for Bubble Cup V8 E Spectator Riots


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
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 S. Every point in S has a probability that a specific player will appear there. Consequently, for every point P in S we know the expected number of fans at it after one second, call it P_e.

Now, for some arbitrary circle that passes through some three points of S (which doesn't violate the rules of the problem), the expected number of fans caught on camera is the sum of all T_e, where T 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 S (otherwise we surely wouldn't catch all points of S with that circle).

Convex hull can be computed in \mathcal O(|S| \log |S|), which might be too slow if unnecessary points are not eliminated from S.

Notice that for every fan in input, if his speed is v, he might appear at \mathcal O(v^2) points, so convex hull algorithm would have \mathcal O(Nv^2 \log(Nv)) complexity, which is too slow.

The trick is to take only the convex hull of those \mathcal O(v^2) points, which will have \mathcal O(1) points. All other points should be eliminated from S as they don't have a chance of appearing on the convex hull of S. Contestants need to be careful with edge cases when a fan potentially goes out of the field.

After computing the convex hull of S (call it H(S)), 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:

  1. 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.
  2. 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 H(S) contains all of the points of H(S) (and then obviously of S) 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

There are no comments at the moment.