Submission #922235

#TimeUsernameProblemLanguageResultExecution timeMemory
922235vjudge1Collecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
23 ms33520 KiB
#include <bits/stdc++.h> #include <iomanip> #define ll long long #define int long long #define pb push_back #define F first #define mpk make_pair #define S second #define st string #define sz(x) x.size() #define all(x) x.begin(), x.end() #define vi vector<int> #define mii map<int,int> #define mll map<ll,ll> #define YES cout<<"YES\n"; #define NO cout<<"NO\n"; #define yes cout<<"Yes\n"; #define no cout<<"No\n"; #define lf else if using namespace std; void why(){ ll n,m,d,k,ans=0; cin>>n>>m>>d>>k; ll pp[n+7][m+7]; for(ll i=0;i<=n;i++){ pp[i][0]=0; } for(ll i=0;i<=m;i++){ pp[0][i]=0; } st v[n+7],s; for(ll i=1;i<=n;i++) { v[i]=" "; cin>>s; v[i]+=s; for(ll j=1;j<=m;j++) { pp[i][j]=(v[i][j]=='S'); pp[i][j]+=pp[i-1][j]; pp[i][j]+=pp[i][j-1]; pp[i][j]-=pp[i-1][j-1]; } } for(ll i=1;i<=n;i++) { for(ll j=1;j<=m;j++) { if(v[i][j]!='M')continue; ll l1=max(i-d,1ll); ll l2=min(i+d,n); ll r1=max(j-d,1ll); ll r2=min(j+d,m); ll an=pp[l2][r2]-pp[l1-1][r2]-pp[l2][r1-1]+pp[l1-1][r1-1]; if(an>=k) { ans++; } } } cout<<ans; } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); //srand( time(0)); //freopen("sum.in", "r", stdin); //freopen("sum.out", "w", stdout); //ll tests=1; //cin>>tests; //for(ll i=1;i<=tests;i++) //{ //cout<<"Case "<<i<<":\n"; why(); //} }
#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...