답안 #1006068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006068 2024-06-23T10:59:47 Z makanhulia Collecting Mushrooms (NOI18_collectmushrooms) C++17
0 / 100
50 ms 27460 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, m, d, s; cin >> n >> m >> d >> s;

    string grid[n + 5];

    for ( int i = 0; i < n; i++) cin >> grid[i];

    int ans[n + 5][m + 5];

    memset ( ans, 0, sizeof(ans));

    for ( int i = 0; i < n; i++){
        for ( int j = 0; j < m; j++){
            if ( grid[i][j] == 'S' ){
                int x1 = max ( 0ll, i - d), x2 = min ( n, i + d);
                int y1 = max ( 0ll, j - d ), y2 = min ( m, j + d);

                ans[x1][y1]++;
                
                if ( y2 + 1 <= m ) ans[x1][y2 + 1]--;
                if ( x2 + 1 <= n ) ans[x2 + 1][y1]--;
                if ( x2 + 1 <= n && y2 + 1 <= m ) ans[x2 + 1][y2 + 1]++;
            }
        }
    }

    int cnt = 0;

    for ( int i = 0; i < n; i++){
        for ( int j = 0; j < m; j++){
            if ( i - 1 >= 0 ){
                ans[i][j] += ans[i - 1][j];
            }
            if ( j - 1 >= 0 ){
                ans[i][j] += ans[i][j - 1];
            }
            if ( i - 1 >= 0 && j - 1 >= 0 ){
                ans[i][j] -= ans[i - 1][j - 1];
            }
        }
    }

    for ( int i = 0; i < n; i++){
        for ( int j = 0; j < m; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    for ( int i = 0; i < n; i++){
        for ( int j = 0; j < m; j++){
            if ( grid[i][j] == 'M' ){
                if ( ans[i][j] >= s ) cnt++; 
            }
        }
    }

    cout << cnt << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 27460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -