제출 #1310259

#제출 시각아이디문제언어결과실행 시간메모리
1310259dgarcia09Collecting Mushrooms (NOI18_collectmushrooms)C++20
60 / 100
2095 ms2240 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; if(r == 1){ char arr[c+1]; vc h, a; for(int i = 1; i <= c; i++){ cin >> arr[i]; if(arr[i] == 'M') h.push_back(i); if(arr[i] == 'S') a.push_back(i); } int cont = 0; for(int i = 0; i < h.size(); i++){ int c = 0; for(int j = 0; j < a.size(); j++){ if(abs(h[i] - a[j]) <= d) c++; } if(c >= k) cont++; } cout << cont << endl; }else{ 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); int cont = 0; for(int i = 0; i < h.size(); i++){ int c = 0; 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) c++; } if(c >= 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...