#P7397. Rainfall Collection on Building Roofs

    ID: 20592 Type: Default 1000ms 256MiB

Rainfall Collection on Building Roofs

Rainfall Collection on Building Roofs

In this problem, each building's roof is modeled as an axis-aligned rectangle, represented by the coordinates of two opposite corners. When rain occurs, a cloud – modeled as a convex polygon – moves in a specified direction with constant speed. Every point in the region traversed by the cloud receives rain. The overall rain area over a time period T corresponds to the union of all positions of the cloud, which is equivalent to the Minkowski sum of the initial polygon and the translation segment from (0, 0) to (dx\times speed\times T, dy\times speed\times T) (all formulas are presented here in LaTeX: \(\vec{v} = (dx\cdot speed \cdot T,\, dy\cdot speed \cdot T)\)).

Your task is to determine the total area of the rooftops that receive rain. For each building, calculate the area of overlap between its rectangular roof and the swept area of the cloud during the rainfall period, and then sum these areas.

inputFormat

The input is given as follows:

  1. The first line contains an integer \(N\), the number of buildings.
  2. Then \(N\) lines follow, each containing four numbers \(x1, y1, x2, y2\) separated by spaces, representing two opposite corners of a building's roof.
  3. The next line contains an integer \(M\), the number of vertices of the convex polygon representing the rain cloud.
  4. Then \(M\) lines follow, each containing two numbers that represent the coordinates of the polygon's vertices in order.
  5. The next line contains two numbers \(dx\) and \(dy\), which indicate the direction vector of the cloud's movement.
  6. The following line contains a number representing the speed of the cloud.
  7. The last line contains a number \(T\), the duration of the rainfall.

Note: The swept area during the rainfall is equivalent to the convex hull of the union of the initial polygon and the polygon after being translated by \(\vec{v} = (dx\cdot speed \cdot T,\, dy\cdot speed \cdot T)\).

outputFormat

Output a single number representing the total area of rooftop that receives rain. An answer is accepted if its absolute or relative error does not exceed \(1\times10^{-6}\).

sample

2
0 0 4 4
5 5 7 8
4
1 1
3 1
3 3
1 3
1 0
1
2
6.0