Submission #1021290

#TimeUsernameProblemLanguageResultExecution timeMemory
1021290lamagrilCollecting Mushrooms (NOI18_collectmushrooms)C++14
19 / 100
24 ms27240 KiB
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(NULL)->sync_with_stdio(false); int n,m,d,k; cin >> n >> m >> d >> k; char mp[n+5][m+5]; int v[n+5][m+5],qs[n+5][m+5]; for(int i=0 ; i<=n ; i++){ for(int j=0 ; j<=m ; j++){ v[i][j]=0; qs[i][j]=0; } } int ans=0; for(int i=1 ; i<=n ; i++){ for(int j=1 ; j<=m ; j++){ cin >> mp[i][j]; } } for(int i=1 ; i<=n ; i++){ for(int j=1 ; j<=m ; j++){ if(mp[i][j]=='S'){ v[1][max(1,j-d)]++; v[1][j+d+1]--; } } } for(int i=1 ; i<=n ; i++){ for(int j=1 ; j<=m ; j++){ qs[i][j]=qs[i][j-1]+v[i][j]; } } for(int i=1 ; i<=n ; i++){ for(int j=1 ; j<=m ; j++){ if(mp[i][j]=='M'){ if(qs[i][j]>=k) ans++; } } } 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...