Submission #515887

# Submission time Handle Problem Language Result Execution time Memory
515887 2022-01-20T04:54:29 Z Joo Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
29 ms 29300 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][max(1, j-D)]--;
                if(j+D+1 <= C) ep[max(1, i-D)][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 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1228 KB Output is correct
2 Correct 5 ms 1484 KB Output is correct
3 Correct 6 ms 1868 KB Output is correct
4 Correct 4 ms 1488 KB Output is correct
5 Correct 5 ms 1580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 29168 KB Output is correct
2 Correct 23 ms 29152 KB Output is correct
3 Correct 22 ms 29300 KB Output is correct
4 Correct 24 ms 29152 KB Output is correct
5 Correct 22 ms 29196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 4 ms 1228 KB Output is correct
17 Correct 5 ms 1484 KB Output is correct
18 Correct 6 ms 1868 KB Output is correct
19 Correct 4 ms 1488 KB Output is correct
20 Correct 5 ms 1580 KB Output is correct
21 Correct 29 ms 29168 KB Output is correct
22 Correct 23 ms 29152 KB Output is correct
23 Correct 22 ms 29300 KB Output is correct
24 Correct 24 ms 29152 KB Output is correct
25 Correct 22 ms 29196 KB Output is correct
26 Correct 13 ms 5940 KB Output is correct
27 Correct 11 ms 3280 KB Output is correct
28 Correct 14 ms 3972 KB Output is correct
29 Correct 12 ms 3712 KB Output is correct
30 Correct 14 ms 5200 KB Output is correct