Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #define int long long
- using namespace std;
- signed main() {
- int n, m, k; cin >> n >> m >> k;
- vector<vector<int>> pref(n + 1, vector<int>(m + 1, 0));
- for(int i = 1; i <= n; ++i)
- for(int j = 1; j <= m; ++j){
- cin >> pref[i][j];
- pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
- }
- while(k--){
- int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
- cout << pref[x2][y2] - pref[x1 - 1][y2] - pref[x2][y1 - 1] + pref[x1 - 1][y1 - 1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement