Submission #921846

#TimeUsernameProblemLanguageResultExecution timeMemory
921846vjudge1Collecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
10 ms8024 KiB
#include <bits/stdc++.h> #define F first #define S second #define ent '\n' //#define int long long #define pb push_back typedef long double ld; typedef long long ll; using namespace std; const int maxn = 1e6+12; const int T = 0; const int mod = 1e9+7; int n,m,k,x,y,l,r; //int ñ[maxn],b[maxn],c[maxn],fact[maxn]; string s,d; void solve(){ cin>>n>>m>>k>>x; char a[n+2][m+2]; int pref[n+2][m+2]; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; pref[i][j]=(a[i][j]=='S') + pref[i][j-1] + pref[i-1][j] - pref[i-1][j-1]; } } int ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='M'){ int l1=max(1,i-k), l2=max(1,j-k) , r1 = min(i+k,n), r2 = min(j+k,m); int cal=pref[r1][r2]+pref[l1-1][l2-1]-(pref[r1][l2-1]+pref[l1-1][r2]); if(cal>=x)ans++; } } } cout<<ans; } //BEKSULTAN TOP signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; if(T)cin>>t; while(t--)solve(); }
#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...