답안 #1021348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021348 2024-07-12T17:11:08 Z lamagril Collecting Mushrooms (NOI18_collectmushrooms) C++14
79 / 100
127 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(NULL)->sync_with_stdio(false);
    int n,m,d,k; cin >> n >> m >> d >> k;
    char mp[n+5][m+5];
    int temp=d;
    if(n==1) d=0;
    int v[n+d+5][m+d+5],qs[n+d+5][m+d+5];
    d=temp;
    for(int i=0 ; i<=n ; i++){
        for(int j=0 ; j<=m ; j++){
            v[i][j]=0;
            qs[i][j]=0;
        }
    }
    int ans=0;
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            cin >> mp[i][j];
        }
    }
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            if(mp[i][j]=='S'){
                if(n==1){
                    v[1][max(1,j-d)]++;
                    v[1][j+d+1]--;
                    continue;
                }
                v[max(1,i-d)][max(1,j-d)]++;
                v[max(1,i-d)][j+d+1]--;
                v[i+d+1][max(1,j-d)]--;
                v[i+d+1][j+d+1]++;
            }
        }
    }
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            qs[i][j]=qs[i-1][j]+qs[i][j-1]-qs[i-1][j-1]+v[i][j];
        }
    }
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            if(mp[i][j]=='M'){
                if(qs[i][j]>=k) ans++;
            }
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5980 KB Output is correct
2 Correct 4 ms 3932 KB Output is correct
3 Correct 5 ms 3164 KB Output is correct
4 Correct 4 ms 5724 KB Output is correct
5 Correct 4 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 27228 KB Output is correct
2 Correct 19 ms 27228 KB Output is correct
3 Correct 19 ms 27228 KB Output is correct
4 Correct 20 ms 27228 KB Output is correct
5 Correct 20 ms 27228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 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 0 ms 348 KB Output is correct
16 Correct 5 ms 5980 KB Output is correct
17 Correct 4 ms 3932 KB Output is correct
18 Correct 5 ms 3164 KB Output is correct
19 Correct 4 ms 5724 KB Output is correct
20 Correct 4 ms 2796 KB Output is correct
21 Correct 20 ms 27228 KB Output is correct
22 Correct 19 ms 27228 KB Output is correct
23 Correct 19 ms 27228 KB Output is correct
24 Correct 20 ms 27228 KB Output is correct
25 Correct 20 ms 27228 KB Output is correct
26 Runtime error 127 ms 262144 KB Execution killed with signal 9
27 Halted 0 ms 0 KB -