Submission #710605

#TimeUsernameProblemLanguageResultExecution timeMemory
710605ToroTNCollecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
17 ms15564 KiB
#include<bits/stdc++.h> using namespace std; int n,m,a1,b1,a2,b2,d,k; int main() { scanf("%d%d%d%d",&n,&m,&d,&k); char s[n+5][m+5]; int sweep[n+5][m+5]; memset(sweep,0,sizeof sweep); for(int i=1;i<=n;i++)scanf("%s",s[i]+1); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { //printf("%c",s[i][j]); if(s[i][j]=='S') { a1=max(1,i-d),b1=max(1,j-d); a2=min(n+1,i+d+1),b2=min(m+1,j+d+1); //printf("%d %d %d %d\n",a1,b1,a2,b2); sweep[a1][b1]+=1; sweep[a1][b2]-=1,sweep[a2][b1]-=1,sweep[a2][b2]+=1; } } //printf("\n"); } int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { sweep[i][j]=sweep[i][j]+sweep[i-1][j]+sweep[i][j-1]-sweep[i-1][j-1]; if(sweep[i][j]>=k&&s[i][j]=='M')++ans; //printf("%d ",sweep[i][j]); } // printf("\n"); } printf("%d\n",ans); }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d%d%d",&n,&m,&d,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
      |                          ~~~~~^~~~~~~~~~~~~
#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...