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>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int r, c, d, k;
int main(){
cin>>r>>c>>d>>k;
char mat[r+1][c+1];
int pref[r+1][c+1];
memset(pref, 0, sizeof(pref));
for(int i = 1; i <= r; i++){
for(int j = 1; j <=c; j++){
cin >> mat[i][j];
pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + (mat[i][j] == 'S');
}
}
ll rez= 0;
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(mat[i][j] == 'M'){
int a = max(i - d, 1),b = max(j - d, 1), x = min(i + d, r), y = min(j + d, c);
int cr = pref[x][y] - pref[x][b- 1] - pref[a - 1][y] + pref[a - 1][b - 1];
rez += (cr >= k);
}
}
}
cout<<rez<<endl;
}
# | 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... |