陈源锋 • 3个月前
using namespace std; int fang[1001][1001] = { 0 }, sum[1001][1001] = { 0 }, q[200001][4] = { 0 }; int main() {
int n, m, q;
cin >> n >> m >> q;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%d",&fang[i][j]);
sum[i][j] = sum[i - 1][j] + sum[i][j - 1] + fang[i][j] - sum[i - 1][j - 1];
}
}
for (int i = 1; i <= q; i++) {
int x1, y1, x2, y2;
scanf("%d %d %d %d",&x1, &y1, &x2, &y2);
printf("%d\n",sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1]);
}
return 0;
}
评论:
请先登录,才能进行评论