Submission #546925

#TimeUsernameProblemLanguageResultExecution timeMemory
546925Ahmed57Collecting Mushrooms (NOI18_collectmushrooms)C++14
0 / 100
14 ms9044 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,m,d,k; cin>>n>>m>>d>>k; char arr[n+1][m+1]; int pre[n+1][m+1]; int fores[n+1][m+1]; memset(pre,0,sizeof pre); memset(fores,0,sizeof fores); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { char a; cin>>a; arr[i][j] = a; if(a=='S'){ fores[max(i-d,1)][max(j-d,1)]++; fores[min(i+d,n)][min(j+d,m)]--; } } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { pre[i][j]=fores[i][j]+pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]; } } int ans=0; for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ if(arr[i][j]=='M'&&pre[i][j]-pre[i-1][j]-pre[i][j-1]+pre[i-1][j-1]>=k){ ans++; } } } cout<<ans; }
#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...