답안 #970415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970415 2024-04-26T13:42:22 Z NoMercy Collecting Mushrooms (NOI18_collectmushrooms) C++14
0 / 100
33 ms 14936 KB
#include <bits/stdc++.h>
using namespace std;
 
    
int TIME = clock();

#define file \
            freopen("in.txt" , "r" , stdin); \
            freopen("out.txt" , "w" , stdout);
 
void test_case () {
    int n , m , d , k;
    cin >> n >> m >> d >> k;
    char c[n + 1][m + 1];
    vector<vector<int>> pre(n + 2 , vector<int> (m + 2 , 0));
    for (int i = 1;i <= n;i ++) {
        for (int j = 1;j <= m;j ++) {
            cin >> c[i][j];
        }
    }
    for (int i = 1;i <= n;i ++) {
        for (int j = 1;j <= m;j ++) {
            if (c[i][j] == 'S') {
                pre[max(0 , i - d)][max(0 , j - d)] ++;
                pre[min(n + 1 , i + d + 1)][min(m + 1 , j + d + 1)] ++;
                pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
                pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
            }
        }
    }
    for (int i = 0;i <= n;i ++) {
        for (int j = 0;j <= m;j ++) {
            if (i > 0) {
                pre[i][j] += pre[i - 1][j];
            }
            if (j > 0) {
                pre[i][j] += pre[i][j - 1];
            }
            if (i > 0 && j > 0) {
                pre[i][j] -= pre[i - 1][j - 1];
            }
        }
    }
    // for (int i = 1;i <= n;i ++) {
    //     for (int j = 1;j <= m;j ++) {
    //         cout << pre[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    int res = 0;
    for (int i = 1;i <= m;i ++) {
        for (int j = 1;j <= m;j ++) {
            res += (c[i][j] == 'M' && pre[i][j] >= k);
        }
    }
    cout << res << "\n";
}

/*


.......
.......
.......
.......
.......

*/
 
int32_t main () {
 
        // file
    
 
    int t = 1;
    // cin >> t;
 
    while (t --) {
        test_case();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2652 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 14936 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -