Submission #1006003

#TimeUsernameProblemLanguageResultExecution timeMemory
1006003kebineCollecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
14 ms5620 KiB
#include <bits/stdc++.h> using namespace std; int main() { int R,C,D,S; cin >> R >> C >> D >> S; string grid[R]; int pref[R+1][C+1]; memset(pref,0,sizeof(pref)); for(int i=0;i<R;i++){ cin >> grid[i]; for(int j=0;j<C;j++){ if(grid[i][j] == 'S'){ int a = max(0,i-D); int b = min(i+D+1,R); int c = max(0,j-D); int d = min(j+D+1,C); pref[a][c]++; pref[a][d]--; pref[b][c]--; pref[b][d]++; } } } for(int i=0;i<R;i++){ for(int j=0;j<C;j++){ if(i > 0){ pref[i][j] += pref[i-1][j]; } if(j > 0){ pref[i][j] += pref[i][j-1]; } if(i > 0 && j > 0){ pref[i][j] -= pref[i-1][j-1]; } } } int ans = 0; for(int i=0;i<R;i++){ for(int j=0;j<C;j++){ if(grid[i][j] == 'M' && pref[i][j] >= S){ 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...