QOJ.ac

QOJ

时间限制: 4 s 内存限制: 512 MB 总分: 100 难度: [显示]

#2309. Bodyguard

统计

Bodyguards

Keli is a playful girl.

When a cute girl goes out to play with friends, she inevitably encounters danger. Therefore, Keli's father has secretly deployed $n$ bodyguards to protect her from the shadows. Because Keli is a strong-willed girl, her father does not want her to know that there are so many bodyguards around her, so the bodyguards must periodically change their posts to avoid being discovered by Keli.

An ideal post change is: bodyguards far from Keli are moved to closer positions, and bodyguards close to Keli are moved to farther positions. After a series of arrangements, the bodyguards will change their posts in the following way:

  • During a post change, the positions of Keli and the bodyguards can be abstracted as points on a two-dimensional Cartesian coordinate system. Let Keli's position be $O$, a bodyguard's position be $P_i$, and the position after the change be $P'_i$.
  • Before and after the change, the relative position of the bodyguard and Keli remains unchanged. That is, for all $i \in [1, n]$, $P'_i$ lies on the ray $OP_i$.
  • Before and after the change, the distance between the bodyguard and Keli becomes its reciprocal. That is, for all $i \in [1, n]$, $|OP_i| \cdot |OP'_i| = 1$.

At the same time, the positions of the bodyguards determine Keli's safety level. If there are more bodyguards on the perimeter, they can observe more information, and Keli is safer. Therefore, we define Keli's safety level as the number of vertices of the convex hull of these bodyguards' positions.

However, Keli's whereabouts are always elusive. One day, the bodyguards lost track of Keli, knowing only that she will appear in a rectangular region with $(x_1, y_1)$ as the bottom-left corner and $(x_2, y_2)$ as the top-right corner, with her specific position following a uniform distribution within this rectangular region (which can be understood as random with equal probability). Because the bodyguards have not changed posts for a long time, they plan to change posts when Keli appears next time. At the same time, with an extremely small probability, Keli might appear at the same position as a certain bodyguard. In this case, this bodyguard will be discovered, so he will keep his position unchanged, while the other bodyguards will still change posts according to the rules above.

Now, Keli's father wants to calculate the expected value of Keli's safety level after the bodyguards change their posts.

If you are not familiar with convex hulls, here is the formal definition:

  • For a simple polygon, it is a convex polygon if and only if the line segment connecting any two points inside it lies entirely within it.
  • For a point set $P$, its convex hull is the convex polygon with the smallest area that contains all points and has no three consecutive vertices collinear.

Input

The first line contains an integer $n$, representing the number of bodyguards. The second line contains four integers $x_1, y_1, x_2, y_2$, representing the rectangular region where Keli may appear. The next $n$ lines each contain two integers $a, b$, representing the coordinates of a bodyguard. It is guaranteed that the coordinates of the bodyguards are distinct.

Output

Output a single real number representing the expected number of vertices of the convex hull. Your answer will be considered correct if the absolute or relative error is within $10^{-7}$ of the standard output.

Examples

Input 1

4
0 0 1 1
0 0
2 0
0 1
1 1

Output 1

3.7853981633974474

Note

The situation when Keli appears at $(1, 0)$ is illustrated below. Bodyguards 1, 2, and 4 remain in their positions $P_1, P_2, P_4$, while bodyguard 3 moves from $P_3$ to $P'_3$ with coordinates $(\frac{1}{2}, \frac{1}{2})$.

At this time, the convex hull of the four bodyguards $P_1, P_2, P'_3, P_4$ is the triangle $P_1, P_4, P_2$, so Keli's safety level is 3. Note that $P'_3$ happens to fall on the edge $P_1P_4$, but according to the definition of a convex hull, it is not a vertex.

Constraints

Test Case $n$ Test Case $n$
1 $\le 3$ 6 $\le 50$
2 $\le 4$ 7 $\le 350$
3 8
4 $\le 50$ 9 $\le 2000$
5 10

For 100% of the data, it is guaranteed that $0 \le a, b, x_1, x_2, y_1, y_2 \le 10^5$, $x_1 < x_2$, $y_1 < y_2$, and $n \ge 3$. For 100% of the data, it is guaranteed that the positions of the bodyguards are distinct. To avoid potential precision errors, in all actual test data and large examples, it is guaranteed that the length and width of the rectangular region where Keli may appear are not less than $10^3$, i.e., $x_2 - x_1, y_2 - y_1 \ge 10^3$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.