-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForest Queries.cpp
More file actions
38 lines (26 loc) · 822 Bytes
/
Copy pathForest Queries.cpp
File metadata and controls
38 lines (26 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int filas, querys, y1, x2, y2, x1;
char c;
cin >> filas >> querys;
vector<vector<int> > matriz(filas + 1, vector<int>(filas + 1));
for(int i = 1; i <= filas; i ++){
for(int j = 1; j <= filas; j ++){
cin >> c;
if(c == '*') matriz[i][j] = 1;
else matriz[i][j] = 0;
matriz[i][j] += matriz[i - 1][j] + matriz[i][j - 1] - matriz[i - 1][j - 1];
//cout << matriz[i][j] << " ";
}
//cout << "\n";
}
while(querys --){
cin >> y1 >> x1 >> y2 >> x2;
cout << matriz[y2][x2] - matriz[y1 - 1][x2] - matriz[y2][x1 - 1] + matriz[y1 - 1][x1 - 1] << "\n";
}
return 0;
}