#P5467. [PKUSC2018] PKUSC

[PKUSC2018] PKUSC

Description

Jiutiao Keliang is a girl who loves playing games.

Recently, she has been playing a hack-and-slash mowing game. There are nn enemies on the plane, and the coordinates of each enemy are xi,yix_i,y_i. Keliang has a skill that allows her to draw a simple polygon with mm points on the plane, and eliminate all enemies that are strictly inside the polygon.

It is not hard to see that if she wants to eliminate enemies quickly, she can just draw a sufficiently large simple polygon. But that would make the game much less fun. So, Keliang decides to add some randomness to the game.

Keliang casually draws a simple polygon with mm points (ai,bi)(a_i,b_i) on the plane. Next, she plans to randomly choose a number α\alpha according to the uniform distribution on [π,π)[-\pi,\pi) (you can think of it as choosing with equal probability), and rotate this simple polygon counterclockwise around the origin by an angle of α\alpha (in radians).

Now Keliang gives you the coordinates of every point and the polygon. Your task is to help Keliang compute the expected number of enemies she can eliminate after a random rotation.

Input Format

The first line contains four integers n,mn,m.

The next nn lines each contain two integers xi,yix_i,y_i, describing the coordinates of an enemy.

The next mm lines each contain two integers ai,bia_i,b_i, describing each vertex of the simple polygon in counterclockwise order.

Output Format

Output one line with one number representing the expected value, rounded to five digits after the decimal point. It is guaranteed that, before rounding, the 66-th digit after the decimal point will not be 44 or 55 for all testdata.

4 4
0 0
1 0
-1 -1
0 1
0 0
1 0
1 1
0 1

0.50000

Hint

Sample Explanation

If you are not very familiar with probability and expectation, here are some hints:

  1. Let PiP_i be the probability that after rotation, exactly ii enemies can be eliminated. Then the expectation is i=1niPi\sum_{i=1}^n iP_i.
  2. One way to compute PiP_i is: among all rotation angles in the range [π,π)[-\pi,\pi), the angles for which exactly ii enemies are eliminated after rotation form tit_i intervals (lj,rj)(l_j,r_j) (whether endpoints are open or closed does not matter). Then Pi=j=1ti(rjlj)2πP_i=\frac{\sum_{j=1}^{t_i}(r_j-l_j)}{2\pi}.

In this problem: the intervals where 00 enemies can be eliminated are [π2,π),[π,π2][\frac{\pi}{2},\pi),[-\pi,-\frac{\pi}{2}], and the intervals where 11 enemy can be eliminated are (π2,0),(0,π2)(-\frac{\pi}{2},0),(0,\frac{\pi}{2}). Therefore, P0=P1=12P_0 = P_1=\frac{1}{2}. So the answer is 12=0.50000\frac{1}{2}=0.50000.

Constraints

For 30%30\% of the data, n,m15n,m \leq 15.

For another 30%30\% of the data, the chosen simple polygon is a convex polygon.

For 100%100\% of the data, n200,m500,x,y106n \leq 200, m \leq 500, |x|,|y| \leq 10^6.

Translated by ChatGPT 5