#B. 子矩阵的元素之和

    Type: Default 1000ms 256MiB

子矩阵的元素之和

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

有一个大小为 n×mn\times m 的矩阵 AA,给出 qq 次询问,每次询问给出 x1y1x2y2x_1、y_1、x_2、y_2 四个数,求以 (x1,y1)(x_1, y_1) 为左上角坐标、(x2,y2)(x_2, y_2) 为右下角坐标的子矩阵中所有元素的和。

输入格式

第 1 行 3 个正整数,分别是 nmq(1n,m1001q104)n、m、q (1 \le n,m \le 100,1 ≤ q ≤ 10^4)

接下来的 nn 行,每行 mm 个数,是矩阵 AA 的元素。每个元素 a(i,j)a(i,j) 值的范围为 100a(i,j)100-100 ≤ a(i,j) ≤ 100

接下来的 qq 行,每行四个整数,分别为每次询问的 x1y1x2y2(1x1x2n1y1y2m)x1、y1、x2、y2 (1 ≤ x1 ≤ x2 ≤ n,1 ≤ y1 ≤ y2 ≤ m)。注意:AA 的行列号从 1 开始,即不存在元素 a[0][i]a[i][0]a[0][i]、a[i][0]

输出格式

输出 qq 行,每行一个整数,为对应查询的子矩阵的元素和。

样例

4 4 2
2 0 4 1
1 8 0 4
1 3 7 3
9 7 6 5
2 2 3 3
1 1 1 1
18
2

C23暑假作业9-杂项-基础题

Not Claimed
Status
Done
Problem
8
Open Since
2024-7-5 0:00
Deadline
2024-10-27 23:59
Extension
24 hour(s)