답안 #94542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94542 2019-01-20T05:46:21 Z FutymyClone Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
26 ms 17164 KB
#include <bits/stdc++.h>

using namespace std;

int n, m, d, k;
vector <vector <int> > f;
vector <vector <char> > a;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> d >> k;
    a.assign(n + 5, vector <char>(m + 5, '#')); f.assign(n + 5, vector <int>(m + 5, 0));
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j] == 'S') {
                int x = i - d, y = j - d, x2 = i + d, y2 = j + d;
                x = max(x, 1); y = max(y, 1); x2 = min(x2, n); y2 = min(y2, m);
                f[x][y]++; f[x2 + 1][y]--; f[x][y2 + 1]--; f[x2 + 1][y2 + 1]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];

    int ans = 0;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (a[i][j] == 'M' && f[i][j] >= k) ans++;
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 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 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 348 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 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1528 KB Output is correct
2 Correct 6 ms 1628 KB Output is correct
3 Correct 7 ms 1912 KB Output is correct
4 Correct 6 ms 1532 KB Output is correct
5 Correct 6 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 17036 KB Output is correct
2 Correct 24 ms 17164 KB Output is correct
3 Correct 23 ms 17036 KB Output is correct
4 Correct 26 ms 17036 KB Output is correct
5 Correct 24 ms 17004 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 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 348 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 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 412 KB Output is correct
16 Correct 6 ms 1528 KB Output is correct
17 Correct 6 ms 1628 KB Output is correct
18 Correct 7 ms 1912 KB Output is correct
19 Correct 6 ms 1532 KB Output is correct
20 Correct 6 ms 1656 KB Output is correct
21 Correct 25 ms 17036 KB Output is correct
22 Correct 24 ms 17164 KB Output is correct
23 Correct 23 ms 17036 KB Output is correct
24 Correct 26 ms 17036 KB Output is correct
25 Correct 24 ms 17004 KB Output is correct
26 Correct 17 ms 5752 KB Output is correct
27 Correct 13 ms 3320 KB Output is correct
28 Correct 13 ms 3704 KB Output is correct
29 Correct 13 ms 3576 KB Output is correct
30 Correct 16 ms 4728 KB Output is correct