#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
bool ckmin(int& a, int b){return b < a ? a = b, 1 : 0;}
bool ckmax(int& a, int b){return b > a ? a = b, 1 : 0;}
const int N = 2e5 + 5, mod = 1e9 + 7;
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int n, m, d, s; cin >> n >> m >> d >> s;
int p[n + 2][m + 2], p2[n + 2][m + 2];
char g[n + 2][m + 2];
int l[n + 2][m + 2], r[n + 2][m + 2];
memset(l, 0, sizeof(l));
memset(r, 0, sizeof(r));
memset(p, 0, sizeof(p));
memset(p2, 0, sizeof(p2));
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> g[i][j];
if(g[i][j] == 'S') {
int i1 = max((int)1, i - d), i2 = min(n + 1, i + d + 1), j1 = max((int)1, j - d), j2 = min(m + 1, j + d + 1);
l[i1][j1]++, l[i2][j1]--, l[i1][j2]--, l[i2][j2]++;
}
}
}
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
l[i][j] = l[i - 1][j] + l[i][j - 1] - l[i - 1][j - 1] + l[i][j];
if(g[i][j] == 'M' && l[i][j] >= s) ans++;
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 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 |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 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 |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6872 KB |
Output is correct |
2 |
Correct |
5 ms |
6912 KB |
Output is correct |
3 |
Correct |
7 ms |
8540 KB |
Output is correct |
4 |
Correct |
5 ms |
7008 KB |
Output is correct |
5 |
Correct |
6 ms |
7424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
48720 KB |
Output is correct |
2 |
Correct |
34 ms |
48732 KB |
Output is correct |
3 |
Correct |
34 ms |
48732 KB |
Output is correct |
4 |
Correct |
34 ms |
48732 KB |
Output is correct |
5 |
Correct |
34 ms |
48724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 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 |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
6 ms |
6872 KB |
Output is correct |
17 |
Correct |
5 ms |
6912 KB |
Output is correct |
18 |
Correct |
7 ms |
8540 KB |
Output is correct |
19 |
Correct |
5 ms |
7008 KB |
Output is correct |
20 |
Correct |
6 ms |
7424 KB |
Output is correct |
21 |
Correct |
34 ms |
48720 KB |
Output is correct |
22 |
Correct |
34 ms |
48732 KB |
Output is correct |
23 |
Correct |
34 ms |
48732 KB |
Output is correct |
24 |
Correct |
34 ms |
48732 KB |
Output is correct |
25 |
Correct |
34 ms |
48724 KB |
Output is correct |
26 |
Correct |
16 ms |
17244 KB |
Output is correct |
27 |
Correct |
18 ms |
16744 KB |
Output is correct |
28 |
Correct |
16 ms |
16988 KB |
Output is correct |
29 |
Correct |
21 ms |
16988 KB |
Output is correct |
30 |
Correct |
16 ms |
17208 KB |
Output is correct |