답안 #154607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154607 2019-09-23T10:04:12 Z dolphingarlic Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
29 ms 12396 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int r, c;
vector<vector<int>> bit, pref;
vector<pair<int, int>> shrooms;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int d, k;
    cin >> r >> c >> d >> k;
    bit.resize(r + 1), pref.resize(r + 1);
    FOR(i, 0, r + 1) bit[i].resize(c + 1), pref[i].resize(c + 1);

    FOR(i, 1, r + 1) {
        FOR(j, 1, c + 1) {
            char c;
            cin >> c;
            if (c == 'S') bit[i][j] = 1;
            else if (c == 'M') shrooms.push_back({i, j});
            pref[i][j] = bit[i][j] + pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
        }
    }

    int ans = 0;
    for (pair<int, int> i : shrooms) {
        int x1 = min(r, i.first + d), x2 = max(0, i.first - d - 1), y1 = min(c, i.second + d), y2 = max(0, i.second - d - 1);
        int cnt = pref[x1][y1] - pref[x1][y2] - pref[x2][y1] + pref[x2][y2];
        if (cnt >= k) ans++;
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1912 KB Output is correct
2 Correct 8 ms 2168 KB Output is correct
3 Correct 9 ms 2680 KB Output is correct
4 Correct 8 ms 2168 KB Output is correct
5 Correct 8 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 10352 KB Output is correct
2 Correct 29 ms 12368 KB Output is correct
3 Correct 28 ms 12396 KB Output is correct
4 Correct 25 ms 10352 KB Output is correct
5 Correct 28 ms 12396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 632 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 7 ms 1912 KB Output is correct
17 Correct 8 ms 2168 KB Output is correct
18 Correct 9 ms 2680 KB Output is correct
19 Correct 8 ms 2168 KB Output is correct
20 Correct 8 ms 2296 KB Output is correct
21 Correct 25 ms 10352 KB Output is correct
22 Correct 29 ms 12368 KB Output is correct
23 Correct 28 ms 12396 KB Output is correct
24 Correct 25 ms 10352 KB Output is correct
25 Correct 28 ms 12396 KB Output is correct
26 Correct 25 ms 7516 KB Output is correct
27 Correct 22 ms 6892 KB Output is correct
28 Correct 20 ms 5880 KB Output is correct
29 Correct 19 ms 6000 KB Output is correct
30 Correct 24 ms 8176 KB Output is correct