답안 #391996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391996 2021-04-20T09:45:12 Z sumit_kk10 Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
15 ms 5196 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int main(){
    fast;
    int n, m, d, k;
    cin >> n >> m >> d >> k;
    char a[n + 1][m + 1];
    int pre_sum[n + 1][m + 1];
    memset(pre_sum, 0, sizeof pre_sum);
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            cin >> a[i][j];
            pre_sum[i][j] = pre_sum[i - 1][j] + pre_sum[i][j - 1] - pre_sum[i - 1][j - 1];
            if(a[i][j] == 'S')
                ++pre_sum[i][j];
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            if(a[i][j] == 'M'){
                int x = max(1, j - d), y = min(m, j + d), x1 = max(1, i - d), y1 = min(n, i + d);
                if((pre_sum[y1][y] - pre_sum[x1 - 1][y] - pre_sum[y1][x - 1] + pre_sum[x1 - 1][x - 1]) >= k) 
                    ++ans;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1412 KB Output is correct
2 Correct 5 ms 1480 KB Output is correct
3 Correct 6 ms 1740 KB Output is correct
4 Correct 5 ms 1484 KB Output is correct
5 Correct 6 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 5192 KB Output is correct
2 Correct 13 ms 5084 KB Output is correct
3 Correct 13 ms 5124 KB Output is correct
4 Correct 14 ms 5196 KB Output is correct
5 Correct 14 ms 5196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 4 ms 1412 KB Output is correct
17 Correct 5 ms 1480 KB Output is correct
18 Correct 6 ms 1740 KB Output is correct
19 Correct 5 ms 1484 KB Output is correct
20 Correct 6 ms 1612 KB Output is correct
21 Correct 14 ms 5192 KB Output is correct
22 Correct 13 ms 5084 KB Output is correct
23 Correct 13 ms 5124 KB Output is correct
24 Correct 14 ms 5196 KB Output is correct
25 Correct 14 ms 5196 KB Output is correct
26 Correct 13 ms 3140 KB Output is correct
27 Correct 12 ms 3148 KB Output is correct
28 Correct 13 ms 3240 KB Output is correct
29 Correct 13 ms 3228 KB Output is correct
30 Correct 15 ms 3148 KB Output is correct