voidbuild(){ preSum[0][0] = 0; for (int i = 1; i < n; ++i) preSum[i][0] = 0; for (int i = 1; i < m; ++i) preSum[0][i] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { preSum[i][j] = preSum[i-1][j] + preSum[i][j-1] - preSum[i-1][j-1] + nums[i-1][j-1]; } } }
intgetSum(int x, int y){ return preSum[x][y]; }
intmain(){ scanf("%d %d %d", &n, &m, &q); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &nums[i][j]); } } build(); int x1, y1, x2, y2; for (int i = 0; i < q; ++i) { scanf("%d %d %d %d", &x1, &y1, &x2, &y2); ans[i] = getSum(x2, y2) - getSum(x2, y1 -1) - getSum(x1 - 1, y2) + getSum(x1 - 1, y1 - 1); } for (int i = 0; i < q; ++i) { printf("%d\n", ans[i]); } return0; }