#P6818. [PA 2013] Działka

[PA 2013] Działka

Problem Description

Given nn points on a k×kk \times k plane and mm queries, for each query, find the area of the convex hull formed by the points inside (including the boundary) an axis-aligned rectangle.

Input Format

The first line contains two positive integers k,nk, n.

The next nn lines each contain two integers xi,yix_i, y_i, representing the coordinates of the ii-th point.

Then a line contains one integer mm.

The next mm lines each contain four numbers ai,bi,ci,dia_i, b_i, c_i, d_i, representing a query rectangle with bottom-left corner (ai,ci)(a_i, c_i) and top-right corner (bi,di)(b_i, d_i).

Output Format

For each query, output one line with the area. Keep one digit after the decimal point.

9 7
1 1
1 3
3 3
3 1
6 5
6 6
7 3
3
0 4 0 4
2 7 0 7
3 7 3 6
4.0
10.0
6.0

Hint

1k1061 \leq k \leq 10^6, 3n3×1033 \leq n \leq 3 \times 10^3, 1m1061 \leq m \leq 10^6, 0xi,yi,ai,bi,ci,dik0 \leq x_i, y_i, a_i, b_i, c_i, d_i \leq k, ai<ci,bi<dia_i < c_i, b_i < d_i.

Translated by ChatGPT 5