Submission #1005987

#TimeUsernameProblemLanguageResultExecution timeMemory
1005987makanhuliaCollecting Mushrooms (NOI18_collectmushrooms)C++17
0 / 100
19 ms27228 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define repp(i,x,n) for(int i=x;i<=n;i++) #define repo(i,x,n) for(int i=x;i>=n;i--) #define cy cout<<"Yes"<<endl #define cn cout<<"No"<<endl #define r0 return 0 #define fi first #define se second #define liow ios_base::sync_with_stdio(false);cin.tie(NULL) #define jelek cout<<"jelek"<<endl #define pii pair<int,int> #define all(v) v.begin(),v.end() #define pi pair<pair<int,int>,pair<int,int>> #define fl fflush(stdout) using namespace std; const int mod=1e9+7,maxn=1e6+5,N=(1<<17),INF=1e18; void solve(){ int r,c,d,s;cin>>r>>c>>d>>s; char a[r+2][c+2]; int arr[r+2][c+2]; memset(arr,0,sizeof arr); repp(i,1,r){ repp(j,1,c){ cin>>a[i][j]; if(a[i][j]=='S'){ int nx=i-d,ny=j-d; if(nx<1) nx=1; if(ny<1) ny=1; arr[nx][ny]++; nx=nx+2*d+1; arr[nx][1]--; ny=ny+2*d+1; arr[nx][ny]--; } } } repp(i,1,r){ repp(j,1,c){ arr[i][j]=arr[i][j]+arr[i-1][j]+arr[i][j-1]-arr[i-1][j-1]; } } int ans=0; repp(i,1,r){ repp(j,1,c){ if(a[i][j]=='M'){ if(arr[i][j]>=s) ans++; } } } cout<<ans; } signed main() { liow; int t=1; // 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...