#include <bits/stdc++.h>
using namespace std;
#define int long long
vector< vector<int> > Graph;
vector< vector<char> > graph;
void upd(int x, int y, int u, int v){
Graph[x][y]++;
Graph[x][v+1]--;
Graph[u+1][y]--;
Graph[u+1][v+1]++;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, d, k;
cin >> n >> m >> d >> k;
Graph.resize(n+2);
graph.resize(n+2);
for(int i = 0; i <= n+1; i++){
Graph[i].resize(m+2);
graph[i].resize(m+2);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <=m; j++){
cin >> graph[i][j];
if(graph[i][j] == 'S'){
upd(max(i-d,(int)1), max(j-d, (int)1), min(i+d,n), min(j+d,m));
}
}
}
int tot = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <=m; j++){
Graph[i][j] += Graph[i][j-1] + Graph[i-1][j] - Graph[i-1][j-1];
if(graph[i][j] == 'M' && Graph[i][j] >= k) tot++;
}
}
cout << tot << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2172 KB |
Output is correct |
2 |
Correct |
6 ms |
2168 KB |
Output is correct |
3 |
Correct |
7 ms |
2808 KB |
Output is correct |
4 |
Correct |
7 ms |
2424 KB |
Output is correct |
5 |
Correct |
7 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
13560 KB |
Output is correct |
2 |
Correct |
21 ms |
13560 KB |
Output is correct |
3 |
Correct |
21 ms |
13560 KB |
Output is correct |
4 |
Correct |
25 ms |
13560 KB |
Output is correct |
5 |
Correct |
22 ms |
13560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
6 ms |
2172 KB |
Output is correct |
17 |
Correct |
6 ms |
2168 KB |
Output is correct |
18 |
Correct |
7 ms |
2808 KB |
Output is correct |
19 |
Correct |
7 ms |
2424 KB |
Output is correct |
20 |
Correct |
7 ms |
2552 KB |
Output is correct |
21 |
Correct |
22 ms |
13560 KB |
Output is correct |
22 |
Correct |
21 ms |
13560 KB |
Output is correct |
23 |
Correct |
21 ms |
13560 KB |
Output is correct |
24 |
Correct |
25 ms |
13560 KB |
Output is correct |
25 |
Correct |
22 ms |
13560 KB |
Output is correct |
26 |
Correct |
20 ms |
7188 KB |
Output is correct |
27 |
Correct |
14 ms |
5320 KB |
Output is correct |
28 |
Correct |
16 ms |
5412 KB |
Output is correct |
29 |
Correct |
15 ms |
5408 KB |
Output is correct |
30 |
Correct |
19 ms |
6520 KB |
Output is correct |