Submission #95077

#TimeUsernameProblemLanguageResultExecution timeMemory
95077ae04071Collecting Mushrooms (NOI18_collectmushrooms)C++11
100 / 100
32 ms23244 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; using pii=pair<int,int>; int n,m,k,d; char str[500010]; vector<int> arr[500010]; vector<pii> ms; inline int gy(int y){return min(max(1,y),n);} inline int gx(int x){return min(max(1,x),m);} int main() { scanf("%d%d%d%d",&n,&m,&d,&k); for(int i=0;i<=n+1;i++) arr[i].resize(m+2,0); for(int i=1;i<=n;i++) { scanf("%s",str+1); for(int j=1;j<=m;j++) { if(str[j]=='M') ms.push_back({i,j}); else if(str[j]=='S') { arr[gy(i-d)][gx(j-d)]+=1; arr[gy(i+d)+1][gx(j-d)]-=1; arr[gy(i-d)][gx(j+d)+1]-=1; arr[gy(i+d)+1][gx(j+d)+1]+=1; } } } for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { arr[i][j] += arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1]; } int ans=0; for(auto &v:ms) if(arr[v.fi][v.se] >= k) ans++; printf("%d\n",ans); return 0; }

Compilation message (stderr)

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