답안 #245847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
245847 2020-07-07T15:11:15 Z zecookiez Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
23 ms 21384 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500002;
vector<int> psa[MAXN];
int main() {
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int r, c, d, k; cin >> r >> c >> d >> k;
    vector<pair<int, int>> mush;
    psa[0].resize(c + 1, 0);
    for(int i = 1; i <= r; ++i){
        string s; cin >> s;
        psa[i].resize(c + 1, 0);
        for(int j = 1; j <= c; ++j){
            if(s[j - 1] == 'M') mush.emplace_back(i, j);
            else if(s[j - 1] == 'S') {
                psa[i][j] = 1;
            }
            psa[i][j] += psa[i][j - 1] + psa[i - 1][j] - psa[i - 1][j - 1];
        }
    }
    int cnt = 0;
    for(auto i : mush){
        int lx = max(1, i.first - d),  rx = min(r, i.first + d);
        int ly = max(1, i.second - d), ry = min(c, i.second + d);
        int tot = psa[rx][ry] - psa[rx][ly - 1] - psa[lx - 1][ry] + psa[lx - 1][ly - 1];
        if(tot >= k) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12032 KB Output is correct
2 Correct 12 ms 12160 KB Output is correct
3 Correct 12 ms 12160 KB Output is correct
4 Correct 12 ms 12160 KB Output is correct
5 Correct 12 ms 12160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12032 KB Output is correct
2 Correct 12 ms 12160 KB Output is correct
3 Correct 12 ms 12160 KB Output is correct
4 Correct 12 ms 12160 KB Output is correct
5 Correct 12 ms 12160 KB Output is correct
6 Correct 12 ms 12032 KB Output is correct
7 Correct 12 ms 12160 KB Output is correct
8 Correct 13 ms 12160 KB Output is correct
9 Correct 12 ms 12160 KB Output is correct
10 Correct 13 ms 12032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12032 KB Output is correct
2 Correct 12 ms 12160 KB Output is correct
3 Correct 13 ms 12288 KB Output is correct
4 Correct 12 ms 12160 KB Output is correct
5 Correct 13 ms 12160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 13056 KB Output is correct
2 Correct 17 ms 13056 KB Output is correct
3 Correct 14 ms 13312 KB Output is correct
4 Correct 14 ms 13056 KB Output is correct
5 Correct 14 ms 13184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 19340 KB Output is correct
2 Correct 23 ms 21384 KB Output is correct
3 Correct 23 ms 21384 KB Output is correct
4 Correct 21 ms 19468 KB Output is correct
5 Correct 23 ms 21384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12032 KB Output is correct
2 Correct 12 ms 12160 KB Output is correct
3 Correct 12 ms 12160 KB Output is correct
4 Correct 12 ms 12160 KB Output is correct
5 Correct 12 ms 12160 KB Output is correct
6 Correct 12 ms 12032 KB Output is correct
7 Correct 12 ms 12160 KB Output is correct
8 Correct 13 ms 12160 KB Output is correct
9 Correct 12 ms 12160 KB Output is correct
10 Correct 13 ms 12032 KB Output is correct
11 Correct 12 ms 12032 KB Output is correct
12 Correct 12 ms 12160 KB Output is correct
13 Correct 13 ms 12288 KB Output is correct
14 Correct 12 ms 12160 KB Output is correct
15 Correct 13 ms 12160 KB Output is correct
16 Correct 16 ms 13056 KB Output is correct
17 Correct 17 ms 13056 KB Output is correct
18 Correct 14 ms 13312 KB Output is correct
19 Correct 14 ms 13056 KB Output is correct
20 Correct 14 ms 13184 KB Output is correct
21 Correct 21 ms 19340 KB Output is correct
22 Correct 23 ms 21384 KB Output is correct
23 Correct 23 ms 21384 KB Output is correct
24 Correct 21 ms 19468 KB Output is correct
25 Correct 23 ms 21384 KB Output is correct
26 Correct 23 ms 15856 KB Output is correct
27 Correct 19 ms 16436 KB Output is correct
28 Correct 18 ms 15476 KB Output is correct
29 Correct 18 ms 15480 KB Output is correct
30 Correct 22 ms 16592 KB Output is correct