P29849 [洛谷] [COI2009] PLAHTE
提高+
题目描述

Problem Description

There are $N$ rectangular sheets on the ground, all parallel to the coordinate axes and none of them cover the point $(0,0)$.

At time $0$, oil covers the grid at $(0,0)$, and every subsequent moment, the oil spreads to the eight adjacent directions. When the oil reaches a grid with a sheet, it contaminates all the sheets on that grid (only the contaminated grids are counted, others are not).

Given certain moments, please calculate the total area of the contaminated grids on all sheets at those moments.

Input Format

The first line contains a positive integer $N$, the number of sheets.

The next $N$ lines each contain four positive integers $x_1, y_1, x_2, y_2$, forming the $i$-th sheet with coordinates $(x_1, y_1)$ and $(x_2, y_2)$.

The next line contains a positive integer $M$, the number of moments.

The next line contains $M$ positive integers, the moments.

Output Format

Output $M$ lines, the $i$-th line being the area of the contaminated sheets at the $i$-th moment (if two sheets overlap, they are counted as two).

Sample Input and Output

Input Sample #1

3
-2 1 1 2
1 0 2 1
-3 -3 -2 0
2
1 2

Output Sample #1

5
15

Input Sample #2

4
5 1 8 4
-8 1 -5 4
-10 2 10 3
6 0 8 10
6
1 2 3 4 7 9

Output Sample #2

0
5
14
18
70
100

Input Sample #3

1
1 1 1000000 1000000
3
100 10000 1000000

Output Sample #3

10000
100000000
1000000000000

Notes

$1 \le N, M \le 10^5$.

$-10^6 \le x_1 \le x_2 \le 10^6, -10^6 \le y_1 \le y_2 \le 10^6$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 -2 1 1 2 1 0 2 1 -3 -3 -2 0 2 1 2
样例输出
5 15