Submission #333493

#TimeUsernameProblemLanguageResultExecution timeMemory
333493fadi57Collecting Mushrooms (NOI18_collectmushrooms)C++14
60 / 100
36 ms7276 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx=1000; const int mod= 998244353; const ll inf=2*1e16+9; int r,c,d,k; int a[mx][mx]; ll pref[mx][mx]; int get(int i){ } int main() { cin>>r>>c>>d>>k; for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ char x;cin>>x; if(x=='.'){ a[i][j]=0; }else if(x=='M'){ a[i][j]=1; }else{ a[i][j]=2; } } } for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ if(a[i][j]==2){ int uper=max(i-d,1); int left=max(j-d,1); // cout<<"hi"<<uper<<" "<<left<<endl; int right=j+d+1; int down=i+d+1; pref[max(i-d,1)][max(j-d,1)]++; pref[max(i-d,1)][j+d+1]--; pref[down][max(j-d,1)]--; pref[down][j+d+1]++; } } } for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ pref[i][j]+=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]; } } int ans=0; for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ // cout<<pref[i][j]<<" "; ans+=(pref[i][j]>=k&&a[i][j]==1); } // cout<<endl; } cout<<ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int get(int)':
mushrooms.cpp:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
   14 | }
      | ^
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:37:21: warning: unused variable 'uper' [-Wunused-variable]
   37 |                 int uper=max(i-d,1);
      |                     ^~~~
mushrooms.cpp:38:15: warning: unused variable 'left' [-Wunused-variable]
   38 |           int left=max(j-d,1);
      |               ^~~~
mushrooms.cpp:40:15: warning: unused variable 'right' [-Wunused-variable]
   40 |           int right=j+d+1;
      |               ^~~~~
#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...