Submission #733825

#TimeUsernameProblemLanguageResultExecution timeMemory
733825vjudge1Collecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
9 ms7360 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, D, K; cin >> N >> M >> D >> K; vector<string> S(N); for (int i = 0; i < N; i++) { cin >> S[i]; } vector pfs(N + 1, vector<int>(M + 1)); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { pfs[i + 1][j + 1] = pfs[i + 1][j] + pfs[i][j + 1] - pfs[i][j] + (S[i][j] == 'S'); } } int ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (S[i][j] == 'M') { int x1 = max(0, i - D); int x2 = min(N, i + D + 1); int y1 = max(0, j - D); int y2 = min(M, j + D + 1); if (pfs[x2][y2] - pfs[x1][y2] - pfs[x2][y1] + pfs[x1][y1] >= K) { ans++; } } } } cout << ans << "\n"; return 6/22; }
#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...