Submission #649589

#TimeUsernameProblemLanguageResultExecution timeMemory
649589ShahdMohamedCollecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
97 ms12520 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]; } vector<vector<ll>>frq(n+1,vector<ll>(m+1)); for (ll i=0; i<n; i++) { for (ll j=0; j<m; j++) { if (v[i][j]=='.' or v[i][j]=='M')continue; if (n<m) { for (ll k=max(0ll,i-x); k<=min(n-1,i+x); k++) { frq[k][max(j-x,0ll)]++; frq[k][min(j+x+1,m)]--; } } else { for (ll k=max(0ll,j-x); k<=min(m-1,j+x); k++) { frq[max(i-x,0ll)][k]++; frq[min(i+x+1,n)][k]--; } } } } if (n<m) { for (ll i=0; i<n; i++) { for (ll j=1; j<m; j++) frq[i][j]+=frq[i][j-1]; } } else { for (ll i=1; i<n; i++) { for (ll j=0; j<m; j++) frq[i][j]+=frq[i-1][j]; } } 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...