#P7397. 雨水收集系统(2021 CoE-I E)

    ID: 6108 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>计算几何2021Special Judge凸包半平面交凸多边形的交

雨水收集系统(2021 CoE-I E)

Description

To simplify the problem, the rooftop of each building is regarded as an axis-aligned rectangle, and the rectangle is represented by the coordinates of two opposite vertices on a diagonal. During each rainfall, the rain cloud moves at a constant speed along a specified direction, and rain falls over the entire region that the cloud passes through. Model the rain cloud as a convex polygon. Given the initial position of the cloud, as well as its moving direction and speed, determine the total area of building rooftops that can receive rainfall within a certain time interval.

Input Format

The input contains multiple test cases.

The first line contains an integer TT, the number of test cases. Then follow TT test cases, with one blank line between every two adjacent test cases.

For each test case, the first line contains an integer nn, the number of buildings. The next nn lines each contain four integers, describing the coordinates of the two diagonal vertices of the rectangle corresponding to the rooftop of the ii-th building.

The next line contains an integer mm, the number of vertices of the convex polygon representing the rain cloud. Then follow mm vertex coordinates of the convex polygon (the order is not guaranteed, i.e., the vertices may not be given in clockwise or counterclockwise order, but the given points uniquely determine the convex polygon representing the rain cloud): (x1x_1, y1y_1), (x2x_2, y2y_2), ..., (xmx_m, ymy_m).

Next come the coordinates of the start point ss (xsx_s, ysy_s) and the end point ee (xex_e, yey_e), indicating that the rain cloud translates along the straight-line direction from ss to ee. After that is an integer vv, meaning the moving speed of the cloud along this direction is vv units of distance per minute. The last line gives the rainfall start time hhstarthh_{start}:mmstartmm_{start} and end time hhendhh_{end}:mmendmm_{end} in 24-hour format.

Output Format

Output the sum of the rooftop areas that can receive rainfall during the specified time interval, accurate to one digit after the decimal point. Your answer is considered correct if its absolute error from the reference output is within 10110^{-1}.

2

2
0 0 10 10
20 20 30 10
4
-10 8 -5 8 -5 13 -10 13
15 0 25 0
1
15:30 16:05

2
0 0 10 10
20 20 30 10
4
-10 8 -5 8 -5 13 -10 13
-5 8 19 1
1
15:30 16:30
50.0
60.5

Hint

Sample Explanation

In the first test case, there are 22 buildings B1\operatorname{B_1} and B2\operatorname{B_2}. The rain cloud C\operatorname{C} is a square (its bottom-left corner is at the point (10-10, 88), with side length 55). The cloud moves uniformly in the direction from the start point (1515, 00) to the end point (2525, 00), at a speed of 11 unit distance per minute. The rainfall starts at 1515:3030 and ends at 1616:0505, so the duration is 3535 minutes, and the cloud moves 3535 units along the arrow direction. As shown, the area that can receive rainfall is the shaded region, which is clearly 50.050.0.

In the second test case, the moving direction of the cloud is different: it moves uniformly in the direction from (5-5, 88) to (1919, 11). The rainfall duration is 6060 minutes, so it moves 6060 units along the arrow direction. All other conditions are the same. The area that can receive rainfall is the shaded region in the figure, and its area is 60.560.5. Note that in the illustration of the second test case, for convenience, the drawn “final position” of the rain cloud is not its actual final position.


Constraints and Notes

For 100%100\% of the testdata: 1T1031 \leq T \leq 10^3, 1n501 \leq n \leq 50, 3m1003 \leq m \leq 100, 0<v1000 \lt v \leq 100. All coordinate values are integers in the closed interval [105,105][-10^5,10^5].

The input guarantees that the rectangles representing building rooftops do not overlap. The rainfall end time is strictly later than the start time. The start point ss and end point ee that define the moving direction are different.

Translated by ChatGPT 5