이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int r, c, d, k;
cin >> r >> c >> d >> k;
char arr[r + 1][c + 1];
int ss[r + 1][c + 1];
memset(ss, 0, sizeof ss);
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
cin >> arr[i][j];
if (arr[i][j] == 'S') {
ss[i][j] = 1;
} else {
ss[i][j] = 0;
}
ss[i][j] = ss[i][j] + ss[i - 1][j] + ss[i][j - 1] - ss[i - 1][j - 1];
}
}
int ans = 0;
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
if (arr[i][j] == 'M') {
int x1 = i - d;
int y1 = j - d;
int x2 = i + d;
int y2 = j + d;
if (x1 <= 0) {
x1 = 1;
}
if (y1 <= 0) {
y1 = 1;
}
if (x2 > r) {
x2 = r;
}
if (y2 > c) {
y2 = c;
}
if (ss[x2][y2] - ss[x1 - 1][y2] - ss[x2][y1 - 1] + ss[x1 - 1][y1 - 1] >= k) {
ans = ans + 1;
}
}
}
}
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... |