제출 #333503

#제출 시각아이디문제언어결과실행 시간메모리
333503fadi57Collecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
50 ms10604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx=2000; const int mod= 998244353; const ll inf=2*1e16+9; int r,c,d,k; int main() { cin>>r>>c>>d>>k; int a[r+6][c+8]; int pref[r+5][c+5]; for(int i=0;i<=r;i++){ for(int j=0;j<=c;j++){ a[i][j]=pref[i][j] =0; } } for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ a[i][j]=pref[i][j] =0; 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)][min(j+d+1,c+1)]--; pref[min(down,r+1)][max(j-d,1)]--; pref[min(down,r+1)][min(j+d+1,c+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; }

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:43:21: warning: unused variable 'uper' [-Wunused-variable]
   43 |                 int uper=max(i-d,1);
      |                     ^~~~
mushrooms.cpp:44:15: warning: unused variable 'left' [-Wunused-variable]
   44 |           int left=max(j-d,1);
      |               ^~~~
mushrooms.cpp:46:15: warning: unused variable 'right' [-Wunused-variable]
   46 |           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...