AT_abc477_f.Count Cells in a Window
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a grid with N rows and M columns. In the i-th row from the top, the squares from the Li-th through Ri-th columns from the left are painted black, and the other squares are painted white.
You are given Q queries. For each query, answer the following question.
- You are given integers A,B,C,D. Find the number of black squares contained in the rectangular region from the A-th through B-th rows from the top and from the C-th through D-th columns from the left.
给你一个 N 行 M 列的网格。在从上往下数第 i 行中,从左往右数第 Li 列到第 Ri 列(含端点)的格子被涂成黑色,其余格子为白色。
你将收到 Q 个查询。对每个查询,请回答以下问题:
- 给定整数 A,B,C,D,求从上往下数第 A 行到第 B 行(含端点)、从左往右数第 C 列到第 D 列(含端点)所构成的矩形区域内包含的黑色格子数量。
输入格式
The input is given from Standard Input in the following format:
N M Q
L1 R1
L2 R2
⋮
LN RN
query1
⋮
queryQ
Each query queryi (1≤i≤Q) is given in the form
A B C D
输入从标准输入中按以下格式给出:
N M Q
L1 R1
L2 R2
⋮
LN RN
query1
⋮
queryQ
每个查询 queryi (1≤i≤Q) 的格式为:
A B C D
输出格式
Output Q lines. The i-th line should contain the answer to the i-th query.
输出 Q 行。第 i 行应包含第 i 个查询的答案。
输入输出样例
输入#1
3 6 3 2 4 1 1 4 6 1 2 1 4 2 3 3 6 1 1 5 6
输出#1
4 3 0
输入#2
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
输出#2
40 15 0 70 27 1 2 5 11 26 8 12
说明/提示
Sample 1 Explanation:

The black squares are located as shown in the figure above. The 1-st query asks for the number of black squares within the blue rectangle at the upper left, the 2-nd query within the red rectangle at the lower right, and the 3-rd query within the green rectangle at the upper right.
Thus, output 4,3,0, respectively.
Constraints
- 1≤N,M,Q≤2×105
- 1≤Li≤Ri≤M
- For each query, 1≤A≤B≤N.
- For each query, 1≤C≤D≤M.
- All input values are integers.
样例 1 解释:

黑色方格的位置如上图所示。第 1 个查询要求计算左上角蓝色矩形区域内的黑色方格数量,第 2 个查询要求计算右下角红色矩形区域内的黑色方格数量,第 3 个查询要求计算右上角绿色矩形区域内的黑色方格数量。
因此,依次输出 4, 3, 0。
限制条件
- 1≤N,M,Q≤2×105
- 1≤Li≤Ri≤M
- 对于每个查询,满足 1≤A≤B≤N。
- 对于每个查询,满足 1≤C≤D≤M。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?