Submission #1059895

#TimeUsernameProblemLanguageResultExecution timeMemory
1059895harzuqiCollecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
27 ms15476 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int X = 2e5 + 5; int n, m, d, k; int main() { cin >> n >> m >> d >> k; int pref[n + 5][m + 5]; char c[n + 5][m + 5]; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> c[i][j]; pref[i][j] = (c[i][j] == 'S') + pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1]; } } int ans = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(c[i][j] != 'M') continue; int cnt = pref[min(n, i+d)][min(m, j+d)] - pref[max(0, i-d-1)][min(m, j+d)] - pref[min(n, i+d)][max(0, j-d-1)] + pref[max(0, i-d-1)][max(0, j-d-1)]; if(cnt >= k) ans++; } } cout << ans << endl; }
#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...