답안 #743626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743626 2023-05-17T14:51:43 Z Fnzx Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
30 ms 32540 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 = 5e4+5;
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+5][m+5] ;
    memset(G , 0 , sizeof(G));


    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:44: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]
   44 |     for(int i=0;i<mushroom.size();i++){
      |                 ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1876 KB Output is correct
2 Correct 4 ms 2132 KB Output is correct
3 Correct 6 ms 2516 KB Output is correct
4 Correct 4 ms 2132 KB Output is correct
5 Correct 4 ms 2260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 28244 KB Output is correct
2 Correct 29 ms 32540 KB Output is correct
3 Correct 29 ms 32532 KB Output is correct
4 Correct 28 ms 28356 KB Output is correct
5 Correct 30 ms 32452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 4 ms 1876 KB Output is correct
17 Correct 4 ms 2132 KB Output is correct
18 Correct 6 ms 2516 KB Output is correct
19 Correct 4 ms 2132 KB Output is correct
20 Correct 4 ms 2260 KB Output is correct
21 Correct 25 ms 28244 KB Output is correct
22 Correct 29 ms 32540 KB Output is correct
23 Correct 29 ms 32532 KB Output is correct
24 Correct 28 ms 28356 KB Output is correct
25 Correct 30 ms 32452 KB Output is correct
26 Correct 15 ms 7496 KB Output is correct
27 Correct 15 ms 8908 KB Output is correct
28 Correct 14 ms 7244 KB Output is correct
29 Correct 14 ms 7292 KB Output is correct
30 Correct 16 ms 9456 KB Output is correct