Submission #515877

# Submission time Handle Problem Language Result Execution time Memory
515877 2022-01-20T04:38:05 Z Joo Collecting Mushrooms (NOI18_collectmushrooms) C++17
38 / 100
27 ms 29284 KB
#include <bits/stdc++.h>
using namespace std;


int main(void){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int R, C, D, K; cin >> R >> C >> D >> K;
    vector<vector<char>> ta(R+10, vector<char>(C+10));
    vector<vector<int>> ep(R+10, vector<int>(C+10));
    
    for(int i = 1; i <= R; i++){
        for(int j = 1; j <= C; j++){
            cin >> ta[i][j];
            if(ta[i][j] == 'S'){
                ep[max(1, i-D)][max(1, j-D)]++;
                if(i+D+1 <= R) ep[i+D+1][j]--;
                if(j+D+1 <= C) ep[i][j+D+1]--;
                if(i+D+1 <= R and j+D+1 <= C) ep[i+D+1][j+D+1]++;
            }
        }
    }

    int ans = 0;
    for(int i = 1; i <= R; i++){
        for(int j = 1; j <= C; j++){
            // cout << ep[i][j] << " ";
            ep[i][j] += ep[i-1][j]+ep[i][j-1]-ep[i-1][j-1];
     
            if(ta[i][j] == 'M' and ep[i][j] >= K){
                ans++;
            }
        }
        // cout << "\n";
    }

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 29272 KB Output is correct
2 Correct 21 ms 29276 KB Output is correct
3 Correct 24 ms 29284 KB Output is correct
4 Correct 27 ms 29260 KB Output is correct
5 Correct 25 ms 29284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Incorrect 1 ms 332 KB Output isn't correct
12 Halted 0 ms 0 KB -