This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int R,C,D,K;
int ans;
int main(){
cin>>R>>C>>D>>K;
char A[R+10][C+10];
int M[R+10][C+10];
for(int i=0;i<R+2;i++)
M[i][0]=0;
for(int j=1;j<C+2;j++)
M[0][j]=0;
for(int i=1;i<R+1;i++)
for(int j=1;j<C+1;j++)
cin>>A[i][j];
for(int i=1;i<R+2;i++)
for(int j=1;j<C+2;j++)
M[i][j]=(A[i][j]=='S')+M[i-1][j]+M[i][j-1]-M[i-1][j-1];
for(int i=1;i<R+1;i++)
for(int j=1;j<C+1;j++)
if(A[i][j]=='M')
ans+=K<=(M[min(R+1,i+D)][min(C+1,j+D)]-M[max(0,i-D-1)][min(C+1,j+D)]-M[min(R+1,i+D)][max(0,j-D-1)]+M[max(0,i-D-1)][max(0,j-D-1)]);
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |