Submission #697407

# Submission time Handle Problem Language Result Execution time Memory
697407 2023-02-09T17:06:53 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
79 / 100
37 ms 3272 KB
#include <bits/stdc++.h>

using namespace std;

int t[1000][1000];
char cc[1000][1000];

int main(){
    int r,c,d,k,cnt=0,i,j;
    cin>>r>>c>>d>>k;
    for(i=1;i<=r;i++){
        for(j=1;j<=c;j++){
            cin>>cc[i][j];
            if(cc[i][j]=='S'){
                int ar=i-d,ac=j-d,br=i+d,bc=j+d;
                if(ar<1)ar=1;
                if(ac<1)ac=1;
                if(br>r)br=r;
                if(bc>c)bc=c;
                t[ar][ac]++;
                t[ar][bc+1]--;
                t[br+1][ac]--;
                t[br+1][bc+1]++;
            }
        }
    }
    for(i=1;i<=r;i++){
        for(j=1;j<=c;j++){
            t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1];
            if(cc[i][j]=='M'&&t[i][j]>=k) cnt++;
        }
    }
    /*for(i=1;i<=r;i++){
        for(j=1;j<=c;j++){
            cout<<t[i][j];
        }
        cout<<"\n";
    }*/
    cout<<cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 700 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 704 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2496 KB Output is correct
2 Correct 13 ms 2772 KB Output is correct
3 Correct 16 ms 2900 KB Output is correct
4 Correct 13 ms 2500 KB Output is correct
5 Correct 13 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3180 KB Output is correct
2 Correct 31 ms 3272 KB Output is correct
3 Correct 31 ms 3216 KB Output is correct
4 Correct 37 ms 3208 KB Output is correct
5 Correct 32 ms 3180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 700 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 704 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 724 KB Output is correct
16 Correct 12 ms 2496 KB Output is correct
17 Correct 13 ms 2772 KB Output is correct
18 Correct 16 ms 2900 KB Output is correct
19 Correct 13 ms 2500 KB Output is correct
20 Correct 13 ms 2772 KB Output is correct
21 Correct 31 ms 3180 KB Output is correct
22 Correct 31 ms 3272 KB Output is correct
23 Correct 31 ms 3216 KB Output is correct
24 Correct 37 ms 3208 KB Output is correct
25 Correct 32 ms 3180 KB Output is correct
26 Runtime error 1 ms 468 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -