Submission #622294

# Submission time Handle Problem Language Result Execution time Memory
622294 2022-08-04T06:20:57 Z Trisanu_Das Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
36 ms 9572 KB
#include <bits/stdc++.h>
#define int long long int

using namespace std;
signed main(){
    int r,c,d,k; cin >> r >> c >> d >> k;
    char a[r+1][c+1];
    int pre[r+1][c+1];
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= c; j++){
            cin >> a[i][j];
        }
    }
    for (int i = 0; i <= r; i++){
        for (int j = 0; j <= c; j++) pre[i][j] = 0;
    }
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= c; j++){
            pre[i][j] = (pre[i-1][j]+pre[i][j-1]+(a[i][j] == 'S'))-pre[i-1][j-1];
        }
    }
    int cnt = 0;
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= c; j++){
            if (a[i][j] != 'M') continue;
            int u = max(i-d,1LL);
            int v = max(j-d, 1LL);
            int w = min(i+d, r);
            int x = min(j+d, c);
            int cur = pre[w][x]-pre[u-1][x]-pre[w][v-1]+pre[u-1][v-1];
            if (cur >= k) cnt++;
        }
    }
    cout << cnt << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2132 KB Output is correct
2 Correct 13 ms 2260 KB Output is correct
3 Correct 17 ms 2740 KB Output is correct
4 Correct 13 ms 2260 KB Output is correct
5 Correct 14 ms 2416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 9568 KB Output is correct
2 Correct 35 ms 9572 KB Output is correct
3 Correct 34 ms 9556 KB Output is correct
4 Correct 35 ms 9456 KB Output is correct
5 Correct 36 ms 9556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 300 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 15 ms 2132 KB Output is correct
17 Correct 13 ms 2260 KB Output is correct
18 Correct 17 ms 2740 KB Output is correct
19 Correct 13 ms 2260 KB Output is correct
20 Correct 14 ms 2416 KB Output is correct
21 Correct 34 ms 9568 KB Output is correct
22 Correct 35 ms 9572 KB Output is correct
23 Correct 34 ms 9556 KB Output is correct
24 Correct 35 ms 9456 KB Output is correct
25 Correct 36 ms 9556 KB Output is correct
26 Correct 31 ms 5076 KB Output is correct
27 Correct 34 ms 5080 KB Output is correct
28 Correct 31 ms 5104 KB Output is correct
29 Correct 33 ms 5240 KB Output is correct
30 Correct 33 ms 5220 KB Output is correct