Submission #649588

#TimeUsernameProblemLanguageResultExecution timeMemory
649588ShahdMohamedCollecting Mushrooms (NOI18_collectmushrooms)C++17
79 / 100
2090 ms6380 KiB
///LW M4 ACC HAZ3L GAMED ///YARAB WALA...I MEAN YARAB ACC #include<bits/stdc++.h> #define ll long long #define ld long double #define endl "\n" const ll mod = (ll) 1e9 + 7; const ll even = (ll) 1e9 + 2; const ll oo= (ll) 1e16; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n,m,x,y; cin>>n>>m>>x>>y; vector<vector<char>>v(n,vector<char>(m)); for (ll i=0; i<n; i++) { for (ll j=0; j<m; j++) cin>>v[i][j]; } if (n==1) { vector<ll>frq(m+1); for (ll i=0; i<n; i++) { for (ll j=0; j<m; j++) { if (v[i][j]=='S') { frq[max(0ll,j-x)]++; frq[min(m,j+x+1)]--; } } } for (ll i=1; i<=m; i++) frq[i]+=frq[i-1]; ll ans=0; for (ll i=0; i<n; i++) { for (ll j=0; j<m; j++) { if (v[i][j]=='M' and frq[j]>=y)ans++; } } cout<<ans<<endl; } else { vector<vector<ll>>frq(n,vector<ll>(m,0)); for (ll i=0; i<n; i++) { for (ll j=0; j<m; j++) { if (v[i][j]=='S') { for (ll k=max(0ll,i-x); k<=min(n-1,i+x); k++) { for (ll h=max(0ll,j-x); h<=min(m-1,j+x); h++) frq[k][h]++; } } } } ll ans=0; for (ll i=0; i<n; i++) { for (ll j=0; j<m; j++) { if (v[i][j]=='M' and frq[i][j]>=y)ans++; } } 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...