#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m, k, d;
cin >> n >> m >> d >> k;
vector<vector<char>> a(n + 2, vector<char>(m + 2));
vector<vector<int>> qs(n + 2, vector<int>(m + 2, 0));
for (int i = 1;i <= n;i++) for (int j = 1;j <= m;j++) {
cin >> a[i][j];
if (a[i][j] == 'S') {
qs[max(1, i - d)][max(1, j - d)]++;
qs[max(1, i - d)][min(m + 1, j + d + 1)]--;
qs[min(n + 1, i + d + 1)][max(1, j - d)]--;
qs[min(n + 1, i + d + 1)][min(m + 1, j + d + 1)]++;
}
}
int ans = 0;
for (int i = 1;i <= n;i++) {
for (int j = 1;j <= m;j++) {
qs[i][j] += qs[i - 1][j] + qs[i][j - 1] - qs[i - 1][j - 1];
if (a[i][j] == 'M' && qs[i][j] >= k) ans++;
}
}
cout << ans;
return 0;
}
# |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 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 |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
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 |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
3 ms |
1372 KB |
Output is correct |
2 |
Correct |
2 ms |
1372 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
1620 KB |
Output is correct |
5 |
Correct |
3 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
9600 KB |
Output is correct |
2 |
Correct |
10 ms |
9584 KB |
Output is correct |
3 |
Correct |
11 ms |
9584 KB |
Output is correct |
4 |
Correct |
11 ms |
9580 KB |
Output is correct |
5 |
Correct |
11 ms |
9584 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
1372 KB |
Output is correct |
17 |
Correct |
2 ms |
1372 KB |
Output is correct |
18 |
Correct |
3 ms |
1884 KB |
Output is correct |
19 |
Correct |
2 ms |
1620 KB |
Output is correct |
20 |
Correct |
3 ms |
1628 KB |
Output is correct |
21 |
Correct |
11 ms |
9600 KB |
Output is correct |
22 |
Correct |
10 ms |
9584 KB |
Output is correct |
23 |
Correct |
11 ms |
9584 KB |
Output is correct |
24 |
Correct |
11 ms |
9580 KB |
Output is correct |
25 |
Correct |
11 ms |
9584 KB |
Output is correct |
26 |
Correct |
10 ms |
4952 KB |
Output is correct |
27 |
Correct |
7 ms |
3420 KB |
Output is correct |
28 |
Correct |
9 ms |
3420 KB |
Output is correct |
29 |
Correct |
8 ms |
3420 KB |
Output is correct |
30 |
Correct |
9 ms |
4668 KB |
Output is correct |