#P7397. 雨水收集系统(2021 CoE-I E)
雨水收集系统(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 , the number of test cases. Then follow test cases, with one blank line between every two adjacent test cases.
For each test case, the first line contains an integer , the number of buildings. The next lines each contain four integers, describing the coordinates of the two diagonal vertices of the rectangle corresponding to the rooftop of the -th building.
The next line contains an integer , the number of vertices of the convex polygon representing the rain cloud. Then follow 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): (, ), (, ), ..., (, ).
Next come the coordinates of the start point (, ) and the end point (, ), indicating that the rain cloud translates along the straight-line direction from to . After that is an integer , meaning the moving speed of the cloud along this direction is units of distance per minute. The last line gives the rainfall start time : and end time : 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 .
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 buildings and . The rain cloud is a square (its bottom-left corner is at the point (, ), with side length ). The cloud moves uniformly in the direction from the start point (, ) to the end point (, ), at a speed of unit distance per minute. The rainfall starts at : and ends at :, so the duration is minutes, and the cloud moves units along the arrow direction. As shown, the area that can receive rainfall is the shaded region, which is clearly .

In the second test case, the moving direction of the cloud is different: it moves uniformly in the direction from (, ) to (, ). The rainfall duration is minutes, so it moves 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 . 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 of the testdata: , , , . All coordinate values are integers in the closed interval .
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 and end point that define the moving direction are different.
Translated by ChatGPT 5
京公网安备 11011102002149号