Submission #743619

# Submission time Handle Problem Language Result Execution time Memory
743619 2023-05-17T14:44:41 Z Fnzx Collecting Mushrooms (NOI18_collectmushrooms) C++17
0 / 100
7 ms 8448 KB
#include<bits/stdc++.h>

using namespace std;

using ll = long long ;
using pii = pair<ll , ll> ;
using i3 = tuple<ll , ll , ll> ;

const int N = 5e5;
const int MOD = 1e9+7 ;

int n , m , d , k , ans;

vector<pii> mushroom ;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m >> d >> k ;

    ll G[n][m] ;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char x ; cin >> x ;
            if(x == 'S'){
                G[i][j]++ ;
            }
            else if(x == 'M'){
                mushroom.push_back({i , j});
            }
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            G[i][j] += G[i-1][j] + G[i][j-1] - G[i-1][j-1] ;
        }
    }

    for(int i=0;i<mushroom.size();i++){
        int uy = mushroom[i].first , ux = mushroom[i].second ;

        int x1 = max(1 , ux - d) , y1 = max(1 , uy - d) ;
        int x2 = min(m , ux + d) , y2 = min(n , uy + d) ;

        ll sum = G[y2][x2] - G[y1 - 1][x2] - G[y2][x1 - 1] + G[y1 - 1][x1 - 1] ;

        if(sum >= k){
            ans++;
        }
    }

    cout << ans ;
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<mushroom.size();i++){
      |                 ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 3796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 8448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -