#include <bits/stdc++.h>
using namespace std;
# define int long long
# define fir first
# define sec second
# define pb push_back
# define endl "\n"
const int cnst = 2e5+5;
bool mutipletestcase = 0;
//bool debug = false;
void solve() {
int n, m, d, s; cin >> n >> m >> d >> s;
char table[n+5][m+5];
int pre[n+5][m+5];
memset(pre, 0, sizeof(pre));
for(int i = 1; i<=n; i++) for(int j = 1; j<=m; j++) {
cin >> table[i][j];
if(table[i][j] == 'S') pre[max(0ll, i-d)][max(0ll, j-d)]++, pre[min(n+1, i+d+1)][min(m+1, j+d+1)]++, pre[max(0ll, i-d)][min(m+1, j+d+1)]--, pre[min(n+1, i+d+1)][max(0ll, j-d)]--;
}
int ans = 0;
for(int i = 1; i<=n; i++) for(int j = 1; j<=m; j++) {
pre[i][j] += pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1];
// cerr << pre[i][j] << " ";
// if(j == m) cerr << endl;
if(table[i][j] == 'M' && pre[i][j] >= d) ans++;
}
cout << ans << endl;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
if(mutipletestcase) cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
26716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |