Submission #1024424

#TimeUsernameProblemLanguageResultExecution timeMemory
1024424thinknoexitCollecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
11 ms9600 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m, k, d; cin >> n >> m >> d >> k; vector<vector<char>> a(n + 2, vector<char>(m + 2)); vector<vector<int>> qs(n + 2, vector<int>(m + 2, 0)); for (int i = 1;i <= n;i++) for (int j = 1;j <= m;j++) { cin >> a[i][j]; if (a[i][j] == 'S') { qs[max(1, i - d)][max(1, j - d)]++; qs[max(1, i - d)][min(m + 1, j + d + 1)]--; qs[min(n + 1, i + d + 1)][max(1, j - d)]--; qs[min(n + 1, i + d + 1)][min(m + 1, j + d + 1)]++; } } int ans = 0; for (int i = 1;i <= n;i++) { for (int j = 1;j <= m;j++) { qs[i][j] += qs[i - 1][j] + qs[i][j - 1] - qs[i - 1][j - 1]; if (a[i][j] == 'M' && qs[i][j] >= k) ans++; } } cout << ans; 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...