Submission #1024422

# Submission time Handle Problem Language Result Execution time Memory
1024422 2024-07-16T04:35:29 Z thinknoexit Collecting Mushrooms (NOI18_collectmushrooms) C++17
0 / 100
13 ms 9584 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m, k, d;
    cin >> n >> m >> d >> k;
    vector<vector<char>> a(n + 2, vector<char>(m + 2));
    vector<vector<int>> qs(n + 2, vector<int>(m + 2, 0));
    for (int i = 1;i <= n;i++) for (int j = 1;j <= m;j++) {
        cin >> a[i][j];
        if (a[i][j] == 'S') {
            qs[max(1, i - d)][max(1, j - d)]++;
            qs[max(1, i - d)][min(n + 1, j + d + 1)]--;
            qs[min(n + 1, i + d + 1)][max(1, j - d)]--;
            qs[min(n + 1, i + d + 1)][min(n + 1, j + d + 1)]++;
        }
    }
    int ans = 0;
    for (int i = 1;i <= n;i++) {
        for (int j = 1;j <= m;j++) {
            qs[i][j] += qs[i - 1][j] + qs[i][j - 1] - qs[i - 1][j - 1];
            if (a[i][j] == 'M' && qs[i][j] >= k) ans++;
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1372 KB Output is correct
2 Runtime error 4 ms 2884 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 9584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -