Submission #1006034

# Submission time Handle Problem Language Result Execution time Memory
1006034 2024-06-23T10:29:46 Z devariaota 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+1)][min(m+1, j+d+1)]++, pre[max(0ll, i-d)][min(m+1, j+d+1)]--, pre[min(n+1, i+d+1)][max(0ll, 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(j == m) cerr << endl;
        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 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 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 2176 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 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -