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 faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define pb push_back
#define task "hetcuu"
using namespace std;
using ll = long long;
using ld = long double;
const ll maxN = 100;
int r,c,d,k,ans = 0;
char a[maxN][maxN];
int pre[maxN][maxN];
int get(int i,int j){
return pre[i][j] + pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1];
}
int main(){
cin >> r >> c >> d >> k;
for(int i = 1; i <= r; i++){
for(int j = 1;j <=c;++j){
cin >> a[i][j];
}
}
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(a[i][j] == 'S'){
int ra = max(1,i-d);
int ca = max(1,j-d);
int rb = min(r,i+d);
int cb = min(c,j+d);
pre[ra][ca]++;
pre[ra][cb+1]--;
pre[rb+1][ca]--;
pre[rb+1][cb+1]++;
}
}
}
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
pre[i][j] = get(i,j);
}
}
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(pre[i][j] >= k && a[i][j] == 'M')ans++;
}
}
cout << ans;
}
# | 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... |