Submission #668239

#TimeUsernameProblemLanguageResultExecution timeMemory
668239600MihneaCollecting Mushrooms (NOI18_collectmushrooms)C++17
60 / 100
2090 ms3676 KiB
#include <bits/stdc++.h> using namespace std; int main() { #ifdef ONPC freopen ("input.txt", "r", stdin); #endif // ONPC #ifndef ONPC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif // ONPC int n, m, r, need; cin >> n >> m >> r >> need; vector<pair<int, int>> mus, spr; for (int i = 0; i < n; i++) { string s; cin >> s; assert((int) s.size() == m); for (int j = 0; j < m; j++) { char ch = s[j]; if (ch == '.') { continue; } if (ch == 'S') { spr.push_back({i, j}); continue; } if (ch == 'M') { mus.push_back({i, j}); continue; } assert(0); } } int sol = 0; for (auto &it : mus) { int cnt = 0; for (auto &j : spr) { int d = max(abs(j.first - it.first), abs(j.second - it.second)); if (d <= r) { cnt++; } } sol += (cnt >= need); } cout << sol << "\n"; }
#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...