답안 #333492

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333492 2020-12-06T13:52:01 Z fadi57 Collecting Mushrooms (NOI18_collectmushrooms) C++14
18 / 100
3 ms 748 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=109;
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

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;
      |               ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 2 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 2 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 2 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -