#P8222. Illumination Operations

    ID: 21401 Type: Default 1000ms 256MiB

Illumination Operations

Illumination Operations

Kid is trapped in a circle centered at \( (0,0) \) with radius \( r \). He has learned a new operation mklig(X,Y,Z) to defeat darkness. In this operation, three distinct points \( X, Y, Z \) (all chosen from a given set of points inside the circle) are used. One draws the rays \( YX \) and \( YZ \) and finds their intersections \( d_1 \) and \( d_2 \) with the circle. Then the region enclosed by the circular arc \( d_1d_2 \) (taken as the minor arc) and the line segments \( Yd_1 \) and \( Yd_2 \) is illuminated.

For a fixed \( r \), let \( S_{\text{light}} \) denote the total area inside the circle that is illuminated (possibly by several operations). In the limit \( r\to\infty \), the ratio \( \frac{S_{\text{light}}}{\pi r^2} \) can be interpreted as the fraction of the plane that is lit. Kid wishes to maximize this ratio. Obviously, if the union of the illuminated regions covers all directions (i.e. the entire circle) then the ratio reaches its maximum value of \( 1 \). However, because the operation mklig is defined by choosing three points, the angular (directional) extent that can be illuminated in one operation is limited by the configuration of points.

More precisely, suppose that for an operation mklig(X,Y,Z) with vertex \( Y \) the two rays \( YX \) and \( YZ \) have directions \( \theta_1 \) and \( \theta_2 \) (measured in \( [0,2\pi) \)). Since the illuminated region is the region bounded by the minor arc between \( d_1 \) and \( d_2 \), the effective illuminated angular interval is \( \min(|\theta_1-\theta_2|,2\pi-|\theta_1-\theta_2|) \).

For each point \( Y \) (used as the vertex), consider all rays from \( Y \) to the other points. Let the sorted angles be \( a_1, a_2,\dots,a_{k} \) (with \( k\ge2 \)) in \( [0,2\pi) \). If we define the gaps \( g_i = a_{i+1}-a_i \) for \( 1\le i<k \) and \( g_k = a_1+2\pi - a_k \), then the maximum angular extent that one can illuminate from \( Y \) (by choosing an appropriate pair among the rays) is \[ L(Y)=2\pi - \max_{1\le i\le k} g_i. \quad (1) \] In other words, regardless of how one chooses the endpoints, the best lighting angle achievable from vertex \( Y \) is \( L(Y) \) and the corresponding illuminated arc (which we denote by \( I_Y \)) is uniquely determined (the arc is taken to be the complement of the largest gap).

Kid is allowed to perform several mklig operations (each determined by one vertex and a pair among its available rays). The union of the illuminated angular intervals (as seen from the circle, which in the limit \( r\to\infty \) represents coverage of the entire circle) determines \( \lim_{r\to\infty}\frac{S_{\text{light}}}{\pi r^2} \). Let \[ U = \bigcup_{Y} I_Y, \quad (2) \] where the union is taken over all possible choices of the vertex (i.e. over all points that have at least two other points to form rays). Kid wants to achieve the maximum possible union \( U \) (which is fixed by the set of points) using as few mklig operations as possible. In other words, he wants to select a subset of vertices whose corresponding intervals cover \( U \) completely. (Note that if \( U \) happens to be the whole circle then \( \lim_{r\to\infty} \frac{S_{\text{light}}}{\pi r^2} = 1 \); otherwise, it is the maximum fraction that can be lit given the points.)

Your task is: Given \( n \) points (each with coordinates \( x, y \)), compute the minimum number of mklig operations required such that the union of the corresponding illuminated angular intervals exactly equals \( U \), the maximum achievable illuminated fraction. You can assume that no three points are collinear.

Input Format: The first line contains an integer \( n \) (\( n\ge3 \)). Each of the next \( n \) lines contains two space‐separated integers \( x \) and \( y \) indicating the coordinates of a point.

Output Format: Output one integer – the minimum number of mklig operations required to achieve the maximum possible \( \lim_{r\to\infty} \frac{S_{\text{light}}}{\pi r^2} \).

inputFormat

The input begins with an integer \( n \) (\( n\ge3 \)), followed by \( n \) lines each containing two integers \( x \) and \( y \) (the coordinates of a point). It is guaranteed that no three points are collinear.

outputFormat

Output a single integer – the minimum number of mklig operations required so that the union of the illuminated angular intervals equals the maximum achievable coverage.

sample

3
0 0
1 0
0 1
3