Submission #925594

# Submission time Handle Problem Language Result Execution time Memory
925594 2024-02-12T05:52:33 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
19 ms 21784 KB
/*
no more temmy :(
*/

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #include<icecream.hpp>
// using namespace icecream;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
// mt19937 rng(1983413);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=5e5+100;
const int M=1e6;
const int B=317;
const int mod=998244353;
const int INF=1e18;
const int lg=64;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-9;
int n,m,d,k;
vector<vector<int>>pref;
int get(int x1,int y1,int x2,int y2){

    return pref[x2][y2]-pref[x2][y1-1]-pref[x1-1][y2]+pref[x1-1][y1-1];
}
void test(){
    cin>>n>>m>>d>>k;
    pref=vector<vector<int>>(n+1,vector<int>(m+1,0));
    vector<pair<int,int>>a,b;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1];
            char x;
            cin>>x;
            if(x=='M'){
                a.push_back({i,j});
            }
            if(x=='S'){
                b.push_back({i,j});
                pref[i][j]++;
            }
        }
    }

    if(b.size()<k){
        cout<<0<<'\n';
        return;
    }
    int ans=0;
    for(auto [x,y]:a){
        int res=get(max(x-d,1ll),max(y-d,1ll),min(x+d,n),min(y+d,m));
        if(res>=k){
            ans++;
        }
    }
    cout<<ans<<'\n';
}
/*

*/  
 
signed main(){
    // ic.prefix("debug->| ");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    long long t2=1;
    //  cin>>t2;
    for(int i=1;i<=t2;i++){
        test();
    }
    
    return 0;
 
}

Compilation message

mushrooms.cpp: In function 'void test()':
mushrooms.cpp:54:16: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   54 |     if(b.size()<k){
      |        ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 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 1 ms 604 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 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1880 KB Output is correct
2 Correct 3 ms 1884 KB Output is correct
3 Correct 4 ms 2440 KB Output is correct
4 Correct 4 ms 1880 KB Output is correct
5 Correct 3 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 16152 KB Output is correct
2 Correct 17 ms 21784 KB Output is correct
3 Correct 15 ms 21272 KB Output is correct
4 Correct 15 ms 19196 KB Output is correct
5 Correct 17 ms 21016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 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 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 3 ms 1880 KB Output is correct
17 Correct 3 ms 1884 KB Output is correct
18 Correct 4 ms 2440 KB Output is correct
19 Correct 4 ms 1880 KB Output is correct
20 Correct 3 ms 2140 KB Output is correct
21 Correct 19 ms 16152 KB Output is correct
22 Correct 17 ms 21784 KB Output is correct
23 Correct 15 ms 21272 KB Output is correct
24 Correct 15 ms 19196 KB Output is correct
25 Correct 17 ms 21016 KB Output is correct
26 Correct 13 ms 9668 KB Output is correct
27 Correct 12 ms 9288 KB Output is correct
28 Correct 13 ms 13072 KB Output is correct
29 Correct 11 ms 7700 KB Output is correct
30 Correct 13 ms 11212 KB Output is correct