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 <bits/stdc++.h>
using namespace std;
#define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define otsumiko exit(0);
#define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >
#define mikochi priority_queue<long long, vector<long long>, greater<long long> >
int main() {
nyahalo
long long r, c, d, k, ans = 0;
cin >> r >> c >> d >> k;
char gr[r+1][c+1];
long long a[r+1][c+1];
memset(a, 0, sizeof(a));
for (long long i=1; i<=r; i++) {
for (long long j=1; j<=c; j++) {
cin >> gr[i][j];
if (gr[i][j] == 'S') {
for (long long ii=max(i-d, 1ll); ii<=min(i+d, r); ii++) {
long long fn = max(j-d, 1ll), sn = min(j+d, c);
a[ii][fn]++;
if (sn<c) {
a[ii][sn+1]--;
}
}
}
}
}
for (long long i=1; i<=r; i++) {
for (long long j=1; j<=c; j++) {
if (j>1) {
a[i][j] += a[i][j-1];
} else {
a[i][j] += a[i-1][c];
}
if (gr[i][j] == 'M' && a[i][j]>=k) {
ans++;
}
}
}
cout << ans << "\n";
otsumiko
}
# | 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... |