Submission #1006093

# Submission time Handle Problem Language Result Execution time Memory
1006093 2024-06-23T11:38:47 Z christinelynn Collecting Mushrooms (NOI18_collectmushrooms) C++17
38 / 100
16 ms 30744 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] - pref[i][max(0LL, j-d-1)] + pref[max(0LL, i-d-1)][max(0LL, j-d-1)] >= s) ans++;
            }
        }
    }
    cout << ans << endl;
  }
}
/*


*/
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 30580 KB Output is correct
2 Correct 14 ms 30556 KB Output is correct
3 Correct 16 ms 30556 KB Output is correct
4 Correct 16 ms 30556 KB Output is correct
5 Correct 14 ms 30744 KB Output is correct
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -