답안 #970319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970319 2024-04-26T10:59:57 Z VMaksimoski008 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
25 ms 7260 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, d, k, ans = 0;
    cin >> n >> m >> d >> k;

    char mat[n+1][m+1];
    int P[n+2][m+2];
    memset(P, 0, sizeof(P));

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            cin >> mat[i][j];
            if(mat[i][j] == 'S') {
                int x1 = max(1, i - d), x2 = min(n, i + d), y1 = max(1, j - d), y2 = min(m, j + d);
                P[x1][y1]++; P[x2+1][y2+1]++;
                P[x1][y2+1]--, P[x2+1][y1]--;
            }
        }
    }

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            P[i][j] += P[i-1][j] + P[i][j-1];
            P[i][j] -= P[i-1][j-1];
            if(P[i][j] >= k && mat[i][j] == 'M') ans++;
        }
    }

    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1372 KB Output is correct
2 Correct 8 ms 1384 KB Output is correct
3 Correct 9 ms 1660 KB Output is correct
4 Correct 8 ms 1368 KB Output is correct
5 Correct 9 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 7260 KB Output is correct
2 Correct 25 ms 7256 KB Output is correct
3 Correct 21 ms 7260 KB Output is correct
4 Correct 23 ms 7260 KB Output is correct
5 Correct 22 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 8 ms 1372 KB Output is correct
17 Correct 8 ms 1384 KB Output is correct
18 Correct 9 ms 1660 KB Output is correct
19 Correct 8 ms 1368 KB Output is correct
20 Correct 9 ms 1372 KB Output is correct
21 Correct 23 ms 7260 KB Output is correct
22 Correct 25 ms 7256 KB Output is correct
23 Correct 21 ms 7260 KB Output is correct
24 Correct 23 ms 7260 KB Output is correct
25 Correct 22 ms 7260 KB Output is correct
26 Correct 21 ms 2904 KB Output is correct
27 Correct 19 ms 2652 KB Output is correct
28 Correct 20 ms 2948 KB Output is correct
29 Correct 21 ms 2952 KB Output is correct
30 Correct 24 ms 3156 KB Output is correct