Submission #624785

# Submission time Handle Problem Language Result Execution time Memory
624785 2022-08-08T18:07:29 Z rm1729 Collecting Mushrooms (NOI18_collectmushrooms) C++14
0 / 100
381 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    int R, C;
    cin  >>R>>C;
    int D, K;
    cin >>D >>K;
    vector <vector <int>> pref(R+1, vector <int> (C+1,0));
    vector <pair<int,int>> loc;
    for(int i=1; i<=R; i++){
        string a;
        cin >>a;
        for(int j=1; j<=C; j++){
            char x = a[j-1];
            pref[i][j]=pref[i][j-1]+pref[i-1][j]-pref[i-1][j-1];
            if(x=='M') loc.push_back(make_pair(i,j));
            if(x=='S'){
                pref[i][j]++;
            } 
        }
    }
    int ans = 0;
    for(auto x: loc){
        pair <int,int> maxpos =make_pair(min(R,x.first+D), min(C,x.second+D));
        pair <int,int> minpos =make_pair(max(1ll,x.first-D), max(1ll,x.second-D));
        int n = pref[maxpos.first][maxpos.second]-pref[minpos.first-1][maxpos.second]-pref[maxpos.first][minpos.second-1]+pref[minpos.first-1][minpos.second-1];
        if(K<=n) ans++;
    }
    cout <<ans<<endl;
}

signed main(){
    int t; cin >>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 381 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -