#D. Problem D. Amazing spacecraft

    传统题 3000ms 128MiB

Problem D. Amazing spacecraft

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

On this day, Sonetto purchased her first spacecraft (which can be considered as a convex polygon) and eagerly began to operate it. This spacecraft had a touch screen interface where the user could click on a position, and the spacecraft would instantly teleport to that location. However, since Sonetto bought a smuggled spacecraft, after Sonetto clicks on a location, the system randomly selects a point within a circle centered at Sonetto0 s clicked position with a radius of R, and the spacecraft teleport to that point.On this day, there was a Mr.Cookie0 s spacecraft parked in the vicinity, which can also be seen as a convex polygon. Now, given the position where Sonetto clicked on the screen, you are asked to calculate the probability of Sonetto0 s spacecraft colliding with Mr.Cookie0 s spacecraft parked in the area. Because the space where Sonetto is located is a rather mysterious space, Sonetto0 s spacecraft may initially intersect with Mr.Cookie0 s spacecraft. However, we don’t need to be concerned about Sonetto0 s initial position. We only need to focus on whether the position of her spacecraft after the instant teleportation will collide with Mr.Cookie0 s spacecraft. To be more specific, you are given two convex polygons A and B, and a circle P (centered at point X with radius R). You need to determine the probability of randomly selecting a point S within the circle P, such that when the convex polygon A moves along the vector OS~ (O is the origin point (0,0)), it transforms into a new convex polygon A0 , and A0 intersects with B (intersection implies that there exists a point w such that w ∈ A0 and w ∈ B).

Input

The input consists of multiple test cases. The first line contains a single integer t(1 ≤ t ≤ 1200) — the number of test cases. Description of the test cases follows. The second line contains a integer n (3 ≤ n ≤ 30000), denoting the number of vertices of the convex polygons A. Then follows n lines, each line contains two integers xi , yi (108xi,yi108−10^8 ≤ xi , yi ≤ 10^8 ), denoting the ith point of the convex polygon A. The points are given in counter-clockwise order. The next line contains a integer m (3m300003 ≤ m ≤ 30000), denoting the number of vertices of the convex polygons B. Then follows m lines, each line contains two integers xi , yi (108xi,yi108−10^8 ≤ x_i , y_i ≤ 10^8 ), denoting the ith point of the convex polygon B. The points are given in counter-clockwise order. The last line contains three integers x,y and r,denoting the position of the center of the circle P and the radius of the circle. (108xi,yi108,0r108−10^8 ≤ xi , yi ≤ 10^8 , 0 ≤ r ≤ 10^8 ) The data guarantees that the sum of n will not exceed 21052 · 10^5 The data guarantees that the sum of m will not exceed 21052 · 10^5

Output

For each test case print a single floating-point number denoting the probability of A0 intersects with B.(keep 4 decimal places)

Samples

2 
5 
0 -2 
4 -1 
4 0 
1 1 
0 0 
4 
0 -2 
3 -1 
2 1 
1 0 
-2 -2 3 
4 
-2 0 
-1 -2 
1 2 
-1 2 
3 
2 0 
5 1 
3 1 
1 -3 4
0.5247 
0.1185

Limitation

3s, 128mb for each test case.

杭电“钉耙编程”挑战(纯英纯硬,持续更新ing)

未参加
状态
已结束
规则
ACM/ICPC
题目
7
开始于
2023-8-5 12:00
结束于
2023-9-24 12:00
持续时间
1200 小时
主持人
参赛人数
28