Submission #133227

#TimeUsernameProblemLanguageResultExecution timeMemory
133227miguelCollecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
25 ms7212 KiB
#include<bits/stdc++.h> using namespace std; #define rc(x) return cout<<x<<endl,0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long //#define int ll #define sz size() #define x first #define y second #define pi pair <int, int> #define pii pair <int, pi> #define vi vector <int> const ll mod = 998244353; int n, m, d, k; int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n>>m>>d>>k; int t[n+2][m+2]; bool ms[n+2][m+2]; for(int i=1; i<=n; i++) for(int j=0; j<=m; j++) ms[i][j]=0; for(int i=0; i<=n; i++) for(int j=0; j<=m; j++) t[i][j]=0; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ char c; cin>>c; if(c=='M') ms[i][j]=1; else if(c=='S'){ t[max(i-d, 1)][max(j-d, 1)]++; t[min(i+d+1, n+1)][max(j-d, 1)]--; t[max(i-d, 1)][min(j+d+1, m+1)]--; t[min(i+d+1, n+1)][min(j+d+1, m+1)]++; } } } int ans=0; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1]; //cout<<t[i][j]<<" "; if(ms[i][j] && t[i][j]>=k) ans++; } //cout<<endl; } 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...