Submission #1059895

# Submission time Handle Problem Language Result Execution time Memory
1059895 2024-08-15T08:56:24 Z harzuqi Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
27 ms 15476 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int X = 2e5 + 5;

int n, m, d, k;

int main() {
    cin >> n >> m >> d >> k;
    int pref[n + 5][m + 5];
    char c[n + 5][m + 5];
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> c[i][j];
            pref[i][j] = (c[i][j] == 'S') + pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1];
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(c[i][j] != 'M') continue;
            int cnt = pref[min(n, i+d)][min(m, j+d)] - pref[max(0, i-d-1)][min(m, j+d)] - pref[min(n, i+d)][max(0, j-d-1)] + pref[max(0, i-d-1)][max(0, j-d-1)];                                
            if(cnt >= k) ans++;
        }
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1372 KB Output is correct
2 Correct 11 ms 1648 KB Output is correct
3 Correct 13 ms 1884 KB Output is correct
4 Correct 7 ms 1628 KB Output is correct
5 Correct 11 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 15452 KB Output is correct
2 Correct 27 ms 15472 KB Output is correct
3 Correct 24 ms 15452 KB Output is correct
4 Correct 22 ms 15476 KB Output is correct
5 Correct 22 ms 15452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 7 ms 1372 KB Output is correct
17 Correct 11 ms 1648 KB Output is correct
18 Correct 13 ms 1884 KB Output is correct
19 Correct 7 ms 1628 KB Output is correct
20 Correct 11 ms 1628 KB Output is correct
21 Correct 23 ms 15452 KB Output is correct
22 Correct 27 ms 15472 KB Output is correct
23 Correct 24 ms 15452 KB Output is correct
24 Correct 22 ms 15476 KB Output is correct
25 Correct 22 ms 15452 KB Output is correct
26 Correct 16 ms 3656 KB Output is correct
27 Correct 16 ms 3304 KB Output is correct
28 Correct 18 ms 3664 KB Output is correct
29 Correct 16 ms 3420 KB Output is correct
30 Correct 17 ms 3688 KB Output is correct