답안 #1006095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006095 2024-06-23T11:41:07 Z makanhulia Collecting Mushrooms (NOI18_collectmushrooms) C++17
0 / 100
33 ms 54036 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define fi first
#define sec second
#define endl '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<ll, null_type,  less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> 

const ll MOD = 998244353;
const ll N = 3e5 + 5;
const ll INF = 1e18;

int32_t main(){
  cin.tie(0)->sync_with_stdio(0);
  int tc = 1;
  // cin >> tc;
  while(tc--){
    ll r,c,d,s; cin >> r >> c >> d >> s;
    char grid[r+5][c+5];
    vector<vector<ll>>pref(r+5, vector<ll>(c+5));
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            cin >> grid[i][j];
        }
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + (grid[i][j] == 'S');
        }
    }
    ll ans = 0;
    for(ll i=1;i<=r;i++){
        for(ll j=1;j<=c;j++){
            if(grid[i][j] == 'M'){
                if(pref[min(r, i+d)][min(c, j+d)] - pref[max(0LL, i-d-1)][j+d] - pref[i+d][max(0LL, j-d-1)] + pref[max(0LL, i-d-1)][max(0LL, j-d-1)] >= s) ans++;
            }
        }
    }
    cout << ans << endl;
  }
}
/*


*/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 4188 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 54036 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -