답안 #995112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995112 2024-06-08T13:04:23 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
12 ms 32340 KB
#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 10;
int n, m, k, d;
string s[maxN];
vector <int> pre[maxN];

int get(int u, int v, int i, int j){
    u = max(u, 1);
    v = max(v, 1);
    i = min(i, n);
    j = min(j, m);
    return pre[i][j] - pre[u - 1][j] - pre[i][v - 1] + pre[u - 1][v - 1];
}

void Init(){
    cin >> n >> m >> d >> k;
    pre[0].resize(m + 1);
    for (int i = 1; i <= n; ++i){
        cin >> s[i];
        s[i] = " " + s[i];
        pre[i].resize(m + 1, 0);
    }
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            pre[i][j] = pre[i][j - 1] + pre[i - 1][j] - pre[i - 1][j - 1] + (s[i][j] == 'S');
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            if (s[i][j] != 'M') continue;
            int cnt = get(i - d, j - d, i + d, j + d);
            if (cnt >= k){
                ++ans;
            }
        }
    }
    cout<<ans;

}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    Init();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27736 KB Output is correct
2 Correct 5 ms 27740 KB Output is correct
3 Correct 5 ms 27740 KB Output is correct
4 Correct 4 ms 27816 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27736 KB Output is correct
2 Correct 5 ms 27740 KB Output is correct
3 Correct 5 ms 27740 KB Output is correct
4 Correct 4 ms 27816 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
6 Correct 4 ms 27736 KB Output is correct
7 Correct 4 ms 27740 KB Output is correct
8 Correct 5 ms 27740 KB Output is correct
9 Correct 4 ms 27772 KB Output is correct
10 Correct 5 ms 27740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 27740 KB Output is correct
2 Correct 4 ms 27740 KB Output is correct
3 Correct 4 ms 27740 KB Output is correct
4 Correct 5 ms 27736 KB Output is correct
5 Correct 4 ms 27740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 29016 KB Output is correct
2 Correct 6 ms 28764 KB Output is correct
3 Correct 6 ms 29112 KB Output is correct
4 Correct 7 ms 28764 KB Output is correct
5 Correct 5 ms 28764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 32260 KB Output is correct
2 Correct 9 ms 32340 KB Output is correct
3 Correct 9 ms 32260 KB Output is correct
4 Correct 9 ms 32260 KB Output is correct
5 Correct 9 ms 32260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27736 KB Output is correct
2 Correct 5 ms 27740 KB Output is correct
3 Correct 5 ms 27740 KB Output is correct
4 Correct 4 ms 27816 KB Output is correct
5 Correct 5 ms 27740 KB Output is correct
6 Correct 4 ms 27736 KB Output is correct
7 Correct 4 ms 27740 KB Output is correct
8 Correct 5 ms 27740 KB Output is correct
9 Correct 4 ms 27772 KB Output is correct
10 Correct 5 ms 27740 KB Output is correct
11 Correct 4 ms 27740 KB Output is correct
12 Correct 4 ms 27740 KB Output is correct
13 Correct 4 ms 27740 KB Output is correct
14 Correct 5 ms 27736 KB Output is correct
15 Correct 4 ms 27740 KB Output is correct
16 Correct 5 ms 29016 KB Output is correct
17 Correct 6 ms 28764 KB Output is correct
18 Correct 6 ms 29112 KB Output is correct
19 Correct 7 ms 28764 KB Output is correct
20 Correct 5 ms 28764 KB Output is correct
21 Correct 9 ms 32260 KB Output is correct
22 Correct 9 ms 32340 KB Output is correct
23 Correct 9 ms 32260 KB Output is correct
24 Correct 9 ms 32260 KB Output is correct
25 Correct 9 ms 32260 KB Output is correct
26 Correct 12 ms 31068 KB Output is correct
27 Correct 8 ms 30144 KB Output is correct
28 Correct 8 ms 30300 KB Output is correct
29 Correct 8 ms 30300 KB Output is correct
30 Correct 12 ms 30808 KB Output is correct