Submission #534064

#TimeUsernameProblemLanguageResultExecution timeMemory
534064gilbirbCollecting Mushrooms (NOI18_collectmushrooms)C++14
60 / 100
2072 ms8500 KiB
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second typedef long long ll; using namespace std; struct range{ ll x1,x2,y1,y2; }; ll r, c, d, k, ans; vector<range>vec; vector<pair<ll,ll>>shroom; map<pair<ll,ll>,ll>mp; bool inside(ll x, ll y){ return (x >= 1 && y >= 1 && x <= r && y <= c); } void check(ll x, ll y){ for(range z : vec){ if(x >= z.x1 && x <= z.x2 && y >= z.y1 && y <= z.y2){ mp[{x,y}]++; if(mp[{x,y}] == k){ ans++; } } } } int main(){ cin >> r >> c >> d >> k; vector<pair<ll,ll>>spr; for(int i = 1; i <= r; i++){ for(int j = 1; j <= c; j++){ char f; cin >> f; if(f == 'M'){ shroom.pb({i,j}); } else if(f == 'S'){ range x; x.x1 = i-d; x.x2 = i+d; x.y1 = j-d; x.y2 = j+d; vec.pb(x); } } } for(pair<ll,ll> x : shroom){ check(x.fi, x.se); } cout << ans << "\n"; }
#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...