Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #define int long long
  4.  
  5. using namespace std;
  6.  
  7. signed main() {
  8.     int n, m, k; cin >> n >> m >> k;
  9.     vector<vector<int>> pref(n + 1, vector<int>(m + 1, 0));
  10.     for(int i = 1; i <= n; ++i)
  11.         for(int j = 1; j <= m; ++j){
  12.             cin >> pref[i][j];
  13.             pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
  14.         }
  15.     while(k--){
  16.         int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
  17.         cout << pref[x2][y2] - pref[x1 - 1][y2] - pref[x2][y1 - 1] + pref[x1 - 1][y1 - 1];
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement