답안 #1015461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015461 2024-07-06T11:12:51 Z overwatch9 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
14 ms 7312 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int r, c, d, k;
    cin >> r >> c >> d >> k;
    vector <string> grid(r+1);
    for (int i = 1; i <= r; i++) {
        cin >> grid[i];
        grid[i] = "0" + grid[i];
    }
    vector <vector <int>> pfx(r+1, vector <int> (c+1));
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            pfx[i][j] = pfx[i-1][j] + pfx[i][j-1] - pfx[i-1][j-1];
            if (grid[i][j] == 'S')
                pfx[i][j]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            if (grid[i][j] != 'M')
                continue;
            // cout << pfx[min(r, i + d)][min(j + d, c)] << '\n';
            // cout << pfx[max(0, i - d - 1)][min(j + d, c)] << '\n';
            // cout << pfx[min(r, i + d)][min(0, j - d - 1)] << '\n';
            int sum = pfx[min(r, i + d)][min(j + d, c)] - pfx[max(0, i - d - 1)][min(j + d, c)] - pfx[min(r, i + d)][max(0, j - d - 1)] + pfx[max(0, i - d - 1)][max(0, j - d - 1)];
            if (sum >= k)
                ans++;
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 436 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1628 KB Output is correct
2 Correct 4 ms 1628 KB Output is correct
3 Correct 7 ms 2012 KB Output is correct
4 Correct 5 ms 1628 KB Output is correct
5 Correct 4 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 7212 KB Output is correct
2 Correct 11 ms 7312 KB Output is correct
3 Correct 11 ms 7212 KB Output is correct
4 Correct 14 ms 7232 KB Output is correct
5 Correct 12 ms 7248 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 4 ms 1628 KB Output is correct
17 Correct 4 ms 1628 KB Output is correct
18 Correct 7 ms 2012 KB Output is correct
19 Correct 5 ms 1628 KB Output is correct
20 Correct 4 ms 1536 KB Output is correct
21 Correct 12 ms 7212 KB Output is correct
22 Correct 11 ms 7312 KB Output is correct
23 Correct 11 ms 7212 KB Output is correct
24 Correct 14 ms 7232 KB Output is correct
25 Correct 12 ms 7248 KB Output is correct
26 Correct 14 ms 5464 KB Output is correct
27 Correct 9 ms 3180 KB Output is correct
28 Correct 9 ms 3356 KB Output is correct
29 Correct 9 ms 3232 KB Output is correct
30 Correct 13 ms 4700 KB Output is correct