Submission #263819

#TimeUsernameProblemLanguageResultExecution timeMemory
263819T0p_Collecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
45 ms16752 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int, int>> mushroom; int main() { int n, m, d, w; scanf(" %d %d %d %d",&n,&m,&d,&w); int qs[n+5][m+5]; memset(qs, 0, sizeof qs); for(int i=1 ; i<=n ; i++) for(int j=1 ; j<=m ; j++) { char c; scanf(" %c",&c); if(c == 'M') mushroom.push_back({i, j}); else if(c == 'S') { int si = max(1, i-d), sj = max(1, j-d), ei = min(n, i+d), ej = min(m, j+d); qs[si][sj]++; qs[si][ej+1]--; qs[ei+1][sj]--; qs[ei+1][ej+1]++; } } for(int i=1 ; i<=n ; i++) for(int j=1 ; j<=m ; j++) qs[i][j] += qs[i-1][j] + qs[i][j-1] - qs[i-1][j-1]; int ans = 0; for(auto x : mushroom) if(qs[x.first][x.second] >= w) ans++; printf("%d\n",ans); return 0; }

Compilation message (stderr)

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