#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>
using namespace std;
const int N = (int)4e5 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7;
int mult(int x, int y) {
return 1ll*x*y%MOD;
}
int sum(int x, int y) {
x += y;
if(x >= MOD) {
x -= MOD;
}
return x;
}
int sub(int x, int y) {
x -= y;
if(x < 0) {
x += MOD;
}
return x;
}
int n, m, d, k;
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cin >> n >> m >> d >> k;
char a[n+1][m+1];
int b[n+5][m+5];
memset(b, 0, sizeof(b));
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
cin >> a[i][j];
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
if(a[i][j] == 'S') {
int x1 = max(1, i-d);
int y1 = max(1, j-d);
int x2 = min(n, i+d);
int y2 = min(m, j+d);
b[x1][y1]++;
b[x1][y2+1]--;
b[x2+1][y1]--;
b[x2+1][y2+1]++;
}
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
b[i][j]+=b[i-1][j];
b[i][j]+=b[i][j-1];
b[i][j]-=b[i-1][j-1];
}
}
int ans = 0;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
ans += (a[i][j] == 'M' && b[i][j] >= k);
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1624 KB |
Output is correct |
2 |
Correct |
3 ms |
1628 KB |
Output is correct |
3 |
Correct |
4 ms |
1884 KB |
Output is correct |
4 |
Correct |
3 ms |
1676 KB |
Output is correct |
5 |
Correct |
4 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
13660 KB |
Output is correct |
2 |
Correct |
14 ms |
13660 KB |
Output is correct |
3 |
Correct |
16 ms |
13664 KB |
Output is correct |
4 |
Correct |
17 ms |
13656 KB |
Output is correct |
5 |
Correct |
15 ms |
13660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
1624 KB |
Output is correct |
17 |
Correct |
3 ms |
1628 KB |
Output is correct |
18 |
Correct |
4 ms |
1884 KB |
Output is correct |
19 |
Correct |
3 ms |
1676 KB |
Output is correct |
20 |
Correct |
4 ms |
1628 KB |
Output is correct |
21 |
Correct |
15 ms |
13660 KB |
Output is correct |
22 |
Correct |
14 ms |
13660 KB |
Output is correct |
23 |
Correct |
16 ms |
13664 KB |
Output is correct |
24 |
Correct |
17 ms |
13656 KB |
Output is correct |
25 |
Correct |
15 ms |
13660 KB |
Output is correct |
26 |
Correct |
9 ms |
3676 KB |
Output is correct |
27 |
Correct |
9 ms |
3420 KB |
Output is correct |
28 |
Correct |
9 ms |
3628 KB |
Output is correct |
29 |
Correct |
9 ms |
3420 KB |
Output is correct |
30 |
Correct |
9 ms |
3420 KB |
Output is correct |