답안 #333503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333503 2020-12-06T14:17:32 Z fadi57 Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
50 ms 10604 KB
#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;
}

Compilation message

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;
      |               ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1940 KB Output is correct
2 Correct 15 ms 1900 KB Output is correct
3 Correct 18 ms 2284 KB Output is correct
4 Correct 15 ms 1900 KB Output is correct
5 Correct 19 ms 2028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 9964 KB Output is correct
2 Correct 40 ms 10092 KB Output is correct
3 Correct 42 ms 9836 KB Output is correct
4 Correct 43 ms 10604 KB Output is correct
5 Correct 42 ms 10604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 14 ms 1940 KB Output is correct
17 Correct 15 ms 1900 KB Output is correct
18 Correct 18 ms 2284 KB Output is correct
19 Correct 15 ms 1900 KB Output is correct
20 Correct 19 ms 2028 KB Output is correct
21 Correct 50 ms 9964 KB Output is correct
22 Correct 40 ms 10092 KB Output is correct
23 Correct 42 ms 9836 KB Output is correct
24 Correct 43 ms 10604 KB Output is correct
25 Correct 42 ms 10604 KB Output is correct
26 Correct 40 ms 5852 KB Output is correct
27 Correct 39 ms 4716 KB Output is correct
28 Correct 41 ms 4844 KB Output is correct
29 Correct 38 ms 4844 KB Output is correct
30 Correct 39 ms 5484 KB Output is correct