이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |