#ABC477F. 窗口内的黑格计数 / Count Cells in a Window
窗口内的黑格计数 / Count Cells in a Window
Problem Statement
You are given a grid with rows and columns. In the -th row from the top, the squares from the -th through -th columns from the left are painted black, and the other squares are painted white.
You are given queries. For each query, answer the following question.
- You are given integers . Find the number of black squares contained in the rectangular region from the -th through -th rows from the top and from the -th through -th columns from the left.
Constraints
- For each query, .
- For each query, .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Each query is given in the form
Output
Output lines. The -th line should contain the answer to the -th query.
3 6 3
2 4
1 1
4 6
1 2 1 4
2 3 3 6
1 1 5 6
4
3
0

The black squares are located as shown in the figure above. The -st query asks for the number of black squares within the blue rectangle at the upper left, the -nd query within the red rectangle at the lower right, and the -rd query within the green rectangle at the upper right.
Thus, output , respectively.
10 20 12
3 8
1 4
12 19
5 14
2 2
9 17
1 20
6 11
16 20
7 7
2 8 4 15
6 10 1 9
3 4 1 4
1 10 1 20
4 9 10 18
5 5 1 20
1 6 8 8
8 10 13 20
2 7 1 5
6 9 6 16
3 10 18 20
7 10 7 12
40
15
0
70
27
1
2
5
11
26
8
12
- Source: AtCoder ABC 477 F
相关
在下列比赛中: