Submission #1006038

# Submission time Handle Problem Language Result Execution time Memory
1006038 2024-06-23T10:32:32 Z makanhulia Collecting Mushrooms (NOI18_collectmushrooms) C++17
18 / 100
30 ms 26744 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(1ll, i-d)][max(1ll, j-d)]++, pre[min(n+1, i+d+1)][min(m+1, j+d+1)]++, pre[max(1ll, i-d)][min(m+1, j+d+1)]--, pre[min(n+1, i+d+1)][max(1ll, 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 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 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 Incorrect 3 ms 2140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 26744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -