Submission #205756

# Submission time Handle Problem Language Result Execution time Memory
205756 2020-02-29T18:23:07 Z Nnandi Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
28 ms 8940 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 500005;
int r, c, d, k;

vector<pair<int,int> > mush;
vector<vector<int> > sums;

int get(int x, int y) {
    x = min(x,r);
    x = max(x,0);
    y = min(y,c);
    y = max(y,0);
    return sums[x][y];
}

bool water_sat(int x, int y) {
    int all = get(x+d,y+d) - get(x-d-1,y+d) - get(x+d,y-d-1) + get(x-d-1,y-d-1);
    int fr = (all >= k) ? 1 : 0;
    return fr;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>r>>c>>d>>k;
    sums.resize(r+1);
    for(int i=0;i<=r;i++) {
        sums[i].resize(c+1);
    }

    for(int i=1;i<=r;i++) {
        for(int j=1;j<=c;j++) {
            char c;
            cin>>c;
            sums[i][j] = sums[i-1][j] + sums[i][j-1] - sums[i-1][j-1];
            if(c == 'S') {
                sums[i][j]++;
            }
            else if(c == 'M') {
                mush.push_back(make_pair(i,j));
            }
        }
    }
    int res = 0;
    for(auto d:mush) {
        res += water_sat(d.first,d.second);
    }
    cout<<res<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 372 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 372 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 636 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1272 KB Output is correct
2 Correct 9 ms 1400 KB Output is correct
3 Correct 10 ms 1532 KB Output is correct
4 Correct 11 ms 1448 KB Output is correct
5 Correct 10 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 6768 KB Output is correct
2 Correct 28 ms 8940 KB Output is correct
3 Correct 26 ms 8940 KB Output is correct
4 Correct 22 ms 6896 KB Output is correct
5 Correct 27 ms 8940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 372 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 372 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 636 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 9 ms 1272 KB Output is correct
17 Correct 9 ms 1400 KB Output is correct
18 Correct 10 ms 1532 KB Output is correct
19 Correct 11 ms 1448 KB Output is correct
20 Correct 10 ms 1400 KB Output is correct
21 Correct 23 ms 6768 KB Output is correct
22 Correct 28 ms 8940 KB Output is correct
23 Correct 26 ms 8940 KB Output is correct
24 Correct 22 ms 6896 KB Output is correct
25 Correct 27 ms 8940 KB Output is correct
26 Correct 26 ms 4736 KB Output is correct
27 Correct 21 ms 4844 KB Output is correct
28 Correct 21 ms 3824 KB Output is correct
29 Correct 19 ms 3952 KB Output is correct
30 Correct 22 ms 5616 KB Output is correct