题目描述
Years after the Ishval Civil War, the Ishvalan refugees have now found a safe place for themselves which is a rectangular piece of land, surrounded by fences.
The land can be thought of as a 2d grid which extends $N$ units vertically and $M$ units horizontally. It is divided into $N$ horizontal rows, which are numbered from $1$ to $N$, as you move from top to bottom and into $M$ vertical columns numbered from $1$ to $M$, from left to right.
There are $X$ rivers flowing in a horizontal direction, each flowing in a different row and covering the entire row. Similarly, there are $Y$ rivers flowing in a vertical direction, each flowing in a different column and covering the entire column.
The people want to build houses of dimensions $S \times S$ on the remaining land.
What is the maximum number of houses of the given dimensions that could be built on the remaining land, such that no part of any house is in a river and no two houses overlap?
------ Input: ------
The first line contains $T$, the number of test cases. Then the test cases follow.
- For each test case, the first line contains $N$ and $M$.
- Then the second line contains $X$ , $Y$ and $S$ denoting the number of rivers flowing horizontally, number of rivers flowing vertically and the dimension of the house.
- The next line contains $X$ integers $x_{i}$ denoting the indices of rows in which river flows horizontally.
- The next line contains $Y$ integers $y_{i}$ denoting the indices of columns in which the river flows vertically.
Note:
$x_{i}$ and $y_{i}$ are given in increasing order.
When $X$ or $Y$ are zero, the line containing $x_{i}$ and $y_{i}$ is skipped respectively in the input (instead of a blank line).
------ Output: ------
For each test case, print a single line containing the maximum number of houses that can be built.
------ Constraints ------
$1≤ T≤ 100$
$1 ≤ N,M ≤ 10^{4}$
$0 ≤ X ≤ N$
$0 ≤ Y ≤ M$
$1 ≤ S ≤ min(N,M)$
$1 ≤ x_{i} ≤ N$
$1 ≤ y_{j} ≤ M$
$x_{i} > x_{i-1}$ for all $2 ≤ i ≤ X$
$y_{i} > y_{i-1}$ for all $2 ≤ i ≤ Y$
----- Sample Input 1 ------
2
7 8
1 2 2
5
4 8
6 5
2 0 1
1 4
----- Sample Output 1 ------
6
20
----- explanation 1 ------
The given figure corresponds to the first test case.
7 8
1 2 2
5
4 8
As shown in the figure, the maximum number of houses of dimension $2\times2$ that could be built on the remaining land is $6$.
输入格式
见题面
输出格式
见题面