Submission #995106

# Submission time Handle Problem Language Result Execution time Memory
995106 2024-06-08T12:58:31 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
13 ms 32932 KB
#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 10;
int n, m, k, d;
string s[maxN];
vector <int> pre[maxN];

int get(int u, int v, int i, int j){
    u = max(u, 1);
    v = max(v, 1);
    i = min(i, n);
    j = min(j, m);
    return pre[i][j] - pre[u - 1][j] - pre[i][v - 1] + pre[u - 1][v - 1];
}

void Init(){
    cin >> n >> m >> d >> k;
    pre[0].resize(m + 1);
    for (int i = 1; i <= n; ++i){
        cin >> s[i];
        s[i] = " " + s[i];
        pre[i].resize(m + 1, 0);
    }
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            pre[i][j] = pre[i][j - 1] + pre[i - 1][j] - pre[i - 1][j - 1] + (s[i][j] == 'S');
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            if (s[i][j] != 'M') continue;
            int cnt = get(i - d, j - d, i + d, j + d);
            if (cnt >= k){
                ++ans;
            }
        }
    }
    cout << ans;

}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    Init();

}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27736 KB Output is correct
2 Correct 5 ms 27740 KB Output is correct
3 Correct 5 ms 27832 KB Output is correct
4 Correct 5 ms 27740 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27736 KB Output is correct
2 Correct 5 ms 27740 KB Output is correct
3 Correct 5 ms 27832 KB Output is correct
4 Correct 5 ms 27740 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
6 Correct 4 ms 27740 KB Output is correct
7 Correct 4 ms 27740 KB Output is correct
8 Correct 5 ms 27736 KB Output is correct
9 Correct 4 ms 27740 KB Output is correct
10 Correct 4 ms 27816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 27740 KB Output is correct
2 Correct 4 ms 27740 KB Output is correct
3 Correct 4 ms 27740 KB Output is correct
4 Correct 4 ms 27736 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 29020 KB Output is correct
2 Correct 5 ms 28888 KB Output is correct
3 Correct 6 ms 29272 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 6 ms 29020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 32772 KB Output is correct
2 Correct 10 ms 32772 KB Output is correct
3 Correct 10 ms 32772 KB Output is correct
4 Correct 11 ms 32932 KB Output is correct
5 Correct 11 ms 32892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27736 KB Output is correct
2 Correct 5 ms 27740 KB Output is correct
3 Correct 5 ms 27832 KB Output is correct
4 Correct 5 ms 27740 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
6 Correct 4 ms 27740 KB Output is correct
7 Correct 4 ms 27740 KB Output is correct
8 Correct 5 ms 27736 KB Output is correct
9 Correct 4 ms 27740 KB Output is correct
10 Correct 4 ms 27816 KB Output is correct
11 Correct 4 ms 27740 KB Output is correct
12 Correct 4 ms 27740 KB Output is correct
13 Correct 4 ms 27740 KB Output is correct
14 Correct 4 ms 27736 KB Output is correct
15 Correct 5 ms 27740 KB Output is correct
16 Correct 6 ms 29020 KB Output is correct
17 Correct 5 ms 28888 KB Output is correct
18 Correct 6 ms 29272 KB Output is correct
19 Correct 6 ms 29020 KB Output is correct
20 Correct 6 ms 29020 KB Output is correct
21 Correct 10 ms 32772 KB Output is correct
22 Correct 10 ms 32772 KB Output is correct
23 Correct 10 ms 32772 KB Output is correct
24 Correct 11 ms 32932 KB Output is correct
25 Correct 11 ms 32892 KB Output is correct
26 Correct 13 ms 31576 KB Output is correct
27 Correct 8 ms 30808 KB Output is correct
28 Correct 8 ms 30808 KB Output is correct
29 Correct 8 ms 30812 KB Output is correct
30 Correct 11 ms 31064 KB Output is correct