Submission #743617

# Submission time Handle Problem Language Result Execution time Memory
743617 2023-05-17T14:43:06 Z Fnzx Collecting Mushrooms (NOI18_collectmushrooms) C++17
79 / 100
22 ms 12036 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 = 1001;
const int MOD = 1e9+7 ;

int n , m , d , k , ans;

ll G[N][N] ;

vector<pii> mushroom ;

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

    cin >> n >> m >> d >> k ;
    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:40: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]
   40 |     for(int i=0;i<mushroom.size();i++){
      |                 ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 848 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 848 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 848 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 1112 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3720 KB Output is correct
2 Correct 6 ms 3904 KB Output is correct
3 Correct 6 ms 4424 KB Output is correct
4 Correct 6 ms 3796 KB Output is correct
5 Correct 6 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 7404 KB Output is correct
2 Correct 22 ms 12036 KB Output is correct
3 Correct 22 ms 10364 KB Output is correct
4 Correct 20 ms 8008 KB Output is correct
5 Correct 19 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 848 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 848 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 584 KB Output is correct
15 Correct 1 ms 980 KB Output is correct
16 Correct 6 ms 3720 KB Output is correct
17 Correct 6 ms 3904 KB Output is correct
18 Correct 6 ms 4424 KB Output is correct
19 Correct 6 ms 3796 KB Output is correct
20 Correct 6 ms 4180 KB Output is correct
21 Correct 15 ms 7404 KB Output is correct
22 Correct 22 ms 12036 KB Output is correct
23 Correct 22 ms 10364 KB Output is correct
24 Correct 20 ms 8008 KB Output is correct
25 Correct 19 ms 11384 KB Output is correct
26 Runtime error 14 ms 9636 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -