Submission #624077

#TimeUsernameProblemLanguageResultExecution timeMemory
624077PoonYaPatCollecting Mushrooms (NOI18_collectmushrooms)C++14
0 / 100
29 ms37832 KiB
#include <bits/stdc++.h> using namespace std; int n,m,d,k,ans; string s[500001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m>>d>>k; for (int i=1; i<=n; ++i) { cin>>s[i]; s[i]=" "+s[i]; } int dp[n][m]; memset(dp,0,sizeof(dp)); for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) { dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]; if (s[i][j]=='S') ++dp[i][j]; } } for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) { if (s[i][j]=='M') { if (dp[min(i+d,n)][min(j+d,m)]-dp[min(i+d,n)][max(0,j-d-1)]-dp[max(0,i-d-1)][min(j+d,m)]+dp[max(0,i-d-1)][max(0,j-d-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...