# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
535355 | MedalistSlayer | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 14 ms | 11312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int N = (int)5e5+10;
int R, C;
int D, K;
char str[N];
int main() {
scanf("%d%d%d%d", &R, &C, &D, &K);
int ans = 0;
vector<vector<int>> pref(R + 1, vector<int>(C + 1, 0));
vector<pair<int, int>> loc;
for (int r = 1; r <= R; r++) {
scanf("%s", str + 1);
for (int c = 1; c <= C; c++) {
char x = str[c];
pref[r][c] = pref[r - 1][c] + pref[r][c - 1] - pref[r - 1][c - 1] + (x == 'S');
if (x == 'M') {
loc.emplace_back(r, c);
}
}
}
for (auto &[r, c] : loc) {
int mnr = max(1, (r - D));
int mnc = max(1, (c - D));
int mxr = min(R, (r + D));
int mxc = min(C, (c + D));
int around = pref[mxr][mxc] - pref[mxr][mnc - 1] - pref[mnr - 1][mxc] + pref[mnr - 1][mnc - 1];
ans += (around >= K);
}
printf("%d", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |