Submission #1015512

#TimeUsernameProblemLanguageResultExecution timeMemory
1015512ag_1204Collecting Mushrooms (NOI18_collectmushrooms)C++17
9 / 100
6 ms7156 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll tt=1; //cin>>tt; while(tt--) { ll r,c,d,k; cin>>r>>c>>d>>k; char grid[r][c]; vector<pair<ll,ll>> mush; for (ll i=0;i<r;i++) { string s; cin>>s; for (ll j=0;j<c;j++) { grid[i][j]=s[j]; if (grid[i][j]=='M') { pair<ll,ll> p; p.first=i; p.second=j; mush.push_back(p); } } } ll ans=0; for (auto p:mush) { ll count=0; ll x1=p.first-d,x2=p.first+d,y1=p.second-d,y2=p.second+d; x1=max(x1,(ll) 0); x2=min(x2,c-1); y1=max(y1,(ll) 0); y2=min(y2,r-1); for (ll i=x1;i<=x2;i++) { for (ll j=y1;j<=y2;j++) { if (grid[i][j]=='S') { count++; } if (count==k) { ans++; break; } } if (count==k) { break; } } } cout<<ans<<endl; } return 0; }
#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...