子矩阵的和
#include<iostream>
using namespace std;
const int N = 200010;
int n, m, q;
int x1, y1, x2, y2;
int A[1010][1010];
int S[1010][1010];
int main() {
scanf("%d%d%d", &n, &m, &q);
for (int i = 1; i <= n; i ++ ) {
for (int j = 1; j <= m; j ++ ) cin >> A[i][j];
}
for (int i = 1; i <= n; i ++ ) {
for (int j = 1; j <= m; j ++ ) S[i][j] = S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1] + A[i][j];
}
for (int i = 0; i < q; i ++ ) {
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
printf("%d\n", S[x2][y2] - S[x1 - 1][y2] - S[x2][y1 - 1] + S[x1 - 1][y1 - 1]);
}
}