Submission #1024421

#TimeUsernameProblemLanguageResultExecution timeMemory
1024421thinknoexitCollecting Mushrooms (NOI18_collectmushrooms)C++17
18 / 100
3 ms2652 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>(n + 2)); vector<vector<int>> qs(n + 2, vector<int>(n + 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(n + 1, j + d + 1)]--; qs[min(n + 1, i + d + 1)][max(1, j - d)]--; qs[min(n + 1, i + d + 1)][min(n + 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...