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 int long long
vector< vector<int> > Graph;
vector< vector<char> > graph;
void upd(int x, int y, int u, int v){
Graph[x][y]++;
Graph[x][v+1]--;
Graph[u+1][y]--;
Graph[u+1][v+1]++;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, d, k;
cin >> n >> m >> d >> k;
Graph.resize(n+2);
graph.resize(n+2);
for(int i = 0; i <= n+1; i++){
Graph[i].resize(m+2);
graph[i].resize(m+2);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <=m; j++){
cin >> graph[i][j];
if(graph[i][j] == 'S'){
upd(max(i-d,(int)1), max(j-d, (int)1), min(i+d,n), min(j+d,m));
}
}
}
int tot = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <=m; j++){
Graph[i][j] += Graph[i][j-1] + Graph[i-1][j] - Graph[i-1][j-1];
if(graph[i][j] == 'M' && Graph[i][j] >= k) tot++;
}
}
cout << tot << 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... |