제출 #1310254

#제출 시각아이디문제언어결과실행 시간메모리
1310254dgarcia09Collecting Mushrooms (NOI18_collectmushrooms)C++20
60 / 100
2093 ms4188 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#define endl '\n' 
#define fr first
#define sc second
#define vc vector<int>
using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); 	cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(0);

    int r, c, d, k;
    cin >> r >> c >> d >> k;
    char arr[r+1][c+1];
    vector<pair<int, int>> h, a;

    for(int i = 1; i <= r; i++){
        for(int j= 1 ;j <= c; j++){
            cin >> arr[i][j];
            if(arr[i][j] == 'M') h.push_back({i,j});
            if(arr[i][j] == 'S') a.push_back({i,j});
        }
    }

    vc hon(h.size(), 0);


    for(int i = 0; i < h.size(); i++){
        for(int j = 0; j < a.size(); j++){
            if((max(abs(h[i].fr - a[j].fr), abs(h[i].sc - a[j].sc))) <= d) hon[i]++;
        }
    }

    int cont = 0;
    for(int i : hon){
        if(i >= k) cont++;
    }

    cout << cont << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...