Submission #742812

# Submission time Handle Problem Language Result Execution time Memory
742812 2023-05-17T02:50:40 Z Fnzx Collecting Mushrooms (NOI18_collectmushrooms) C++17
79 / 100
21 ms 10180 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;

int 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) ;

        int 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 0 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 852 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 0 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 852 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 724 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 588 KB Output is correct
3 Correct 1 ms 984 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2060 KB Output is correct
2 Correct 4 ms 2260 KB Output is correct
3 Correct 5 ms 2464 KB Output is correct
4 Correct 4 ms 2136 KB Output is correct
5 Correct 4 ms 2420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 5236 KB Output is correct
2 Correct 18 ms 10180 KB Output is correct
3 Correct 17 ms 9676 KB Output is correct
4 Correct 14 ms 6092 KB Output is correct
5 Correct 21 ms 10028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 852 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 724 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 588 KB Output is correct
13 Correct 1 ms 984 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 852 KB Output is correct
16 Correct 5 ms 2060 KB Output is correct
17 Correct 4 ms 2260 KB Output is correct
18 Correct 5 ms 2464 KB Output is correct
19 Correct 4 ms 2136 KB Output is correct
20 Correct 4 ms 2420 KB Output is correct
21 Correct 15 ms 5236 KB Output is correct
22 Correct 18 ms 10180 KB Output is correct
23 Correct 17 ms 9676 KB Output is correct
24 Correct 14 ms 6092 KB Output is correct
25 Correct 21 ms 10028 KB Output is correct
26 Runtime error 7 ms 9176 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -