Submission #547792

#TimeUsernameProblemLanguageResultExecution timeMemory
547792unicornboyCollecting Mushrooms (NOI18_collectmushrooms)C++14
60 / 100
2072 ms3764 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second using namespace std; const int N=5e5+1; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); ll n , m , d , k; cin >> n >> m >> d >> k ; vector<pair<int,int>>mushrooms; vector<pair<int,int>>sprinklers; for (int i=0;i<n;i++) { for (int j=0;j<m;j++) { char c; cin >> c ; if(c=='M') { mushrooms.pb({i,j}); } else if (c=='S') { sprinklers.pb({i,j}); } } } // iterate on each sprinkler for each mushroom int ans=0; for (int i=0;i<mushrooms.size();i++) { int count=0; for (int j=0;j<sprinklers.size();j++) { int dis=max(abs(sprinklers[j].ff-mushrooms[i].ff),abs(sprinklers[j].ss-mushrooms[i].ss)); if(dis<=d) { count++; } if(count>=k) break; } if(count>=k) ans++; } cout<<ans<<"\n"; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i=0;i<mushrooms.size();i++)
      |                  ~^~~~~~~~~~~~~~~~~
mushrooms.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int j=0;j<sprinklers.size();j++)
      |                      ~^~~~~~~~~~~~~~~~~~
#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...