Submission #131237

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1312372019-07-16 20:40:43FedericoSCollecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
79 ms27640 KiB
#include <iostream>
#include <cstring>
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];
memset(A, 0, sizeof A);
memset(M, 0, sizeof M);
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;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...