#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,d,k;
cin>>n>>m>>d>>k;
char arr[n+1][m+1];
int pre[n+1][m+1];
int fores[n+1][m+1];
memset(pre,0,sizeof pre);
memset(fores,0,sizeof fores);
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
char a;
cin>>a;
arr[i][j] = a;
if(a=='S'){
fores[max(i-d,1)][max(j-d,1)]++;
fores[min(i+d,n)][min(j+d,m)]--;
}
}
}
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
pre[i][j]=fores[i][j]+pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];
}
}
int ans=0;
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
if(arr[i][j]=='M'&&pre[i][j]-pre[i-1][j]-pre[i][j-1]+pre[i-1][j-1]>=k){
ans++;
}
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
9044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |