6 条题解
-
1
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; const int INF = 0x3f3f3f3f; long long n , m , p , q , x , y , x2 , y2 , z; long long cf[N][N] , a[N][N] , s[N][N]; int main() { cin >> n >> m >> p >> q; for( int i = 1 ; i <= n ; i++ ) { for( int j = 1 ; j <= m ; j++ ) { cin >> a[i][j]; cf[i][j] = a[i][j] - a[i-1][j] - a[i][j-1] + a[i-1][j-1]; } } while( p-- ) { cin >> x >> y >> x2 >> y2 >> z; cf[x][y] += z; cf[x][y2+1] -= z; cf[x2+1][y] -= z; cf[x2+1][y2+1] += z; } for( int i = 1 ; i <= n ; i++ ) { for( int j = 1 ; j <= m ; j++ ) { a[i][j] = a[i-1][j] + a[i][j-1] - a[i-1][j-1] + cf[i][j]; s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + a[i][j]; cout << a[i][j] << " "; } cout << endl; } while( q-- ) { cin >> x >> y >> x2 >> y2; cout << s[x2][y2] - s[x-1][y2] - s[x2][y-1] + s[x-1][y-1] << endl; } return 0; }
信息
- ID
- 1285
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 690
- 已通过
- 143
- 上传者