#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>(n + 2));
vector<vector<int>> qs(n + 2, vector<int>(n + 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(n + 1, j + d + 1)]--;
qs[min(n + 1, i + d + 1)][max(1, j - d)]--;
qs[min(n + 1, i + d + 1)][min(n + 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
428 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2652 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |