Submission #1006028

# Submission time Handle Problem Language Result Execution time Memory
1006028 2024-06-23T10:26:35 Z kebine Collecting Mushrooms (NOI18_collectmushrooms) C++17
0 / 100
22 ms 26716 KB
#include <bits/stdc++.h>
using namespace std;

# define int long long
# define fir first
# define sec second
# define pb push_back
# define endl "\n"

const int cnst = 2e5+5;
bool mutipletestcase = 0;
//bool debug = false;

void solve() {
    int n, m, d, s; cin >> n >> m >> d >> s;

    char table[n+5][m+5];
    int pre[n+5][m+5];

    memset(pre, 0, sizeof(pre));

    for(int i = 1; i<=n; i++) for(int j = 1; j<=m; j++) {
        cin >> table[i][j];

        if(table[i][j] == 'S') pre[max(0ll, i-d)][max(0ll, j-d)]++, pre[min(n+1, i+d)][min(m+1, j+d)]--;
    }

    int ans = 0;
    for(int i = 1; i<=n; i++) for(int j = 1; j<=m; j++) {
        pre[i][j] += pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1];
        // cerr << pre[i][j] << " ";
        if(table[i][j] == 'M' && pre[i][j] >= d) ans++;
    }

    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1;
    if(mutipletestcase) cin >> t; 
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 Incorrect 3 ms 2220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 26716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -