#P4502. Expected Security Degree

    ID: 17748 Type: Default 1000ms 256MiB

Expected Security Degree

Expected Security Degree

A little girl, Jiutiao Kelian, loves to play. In order to keep her safe without letting her know, her father secretly places n bodyguards around her. When it is time to swap shifts, the bodyguards change their positions according to a rather peculiar rule: if the girl’s position is denoted by \(O\) and a guard’s original position by \(P_i\), then after swapping the new position \(P'_i\) is chosen on the ray \(OP_i\) such that

\( |OP_i|\times|OP'_i| = 1 \)

That is, with respect to the girl, the distances get inverted. (Note that in the extremely unlikely case that the girl appears exactly at a guard’s position, that guard will be discovered and will not change his position.)

The safety level of the girl is determined by the number of vertices of the convex hull of the bodyguards’ positions after the swap. (For those not too familiar with convex hulls: given a set of points, its convex hull is defined as the smallest convex polygon that contains all the points, with the additional condition that no three consecutive vertices are collinear.)

Just after a long time with no swapping, the bodyguards have lost track of the girl. They only know that her next appearance will be uniformly random in the axis‐aligned rectangle whose lower–left corner is \( (x_1,y_1) \) and upper–right corner is \( (x_2,y_2) \). At that moment the bodyguards will carry out the swapping procedure described above. Your task is to compute the expected safety level (i.e. the expected number of vertices of the convex hull of the swapped positions) over the randomness of the girl’s eventual position.

Input Note: The positions of the bodyguards and the girl are points in the Euclidean plane. For each guard \(i\) with original position \(P_i\), if \(P_i \neq O\) then his new position is computed as

\(P'_i = O + \frac{P_i-O}{|P_i-O|^2}\).

inputFormat

The first line contains an integer \(n\) (the number of bodyguards). The next \(n\) lines each contain two real numbers, representing the coordinates of a bodyguard. The last line contains four real numbers \(x_1\), \(y_1\), \(x_2\), \(y_2\) representing the lower–left and upper–right corners of the rectangle in which the girl will appear.

outputFormat

Output a single real number: the expected safety level (i.e. expected number of vertices of the convex hull of the bodyguards’ new positions) after the swapping operation. Your answer is accepted if its absolute or relative error does not exceed \(10^{-6}\).

sample

1
1.0 0.0
0.0 0.0 1.0 1.0
1.000000

</p>