이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pff pair<float, float>
#define coutpair(p) cout << p.first << " " << p.second << "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll r, c, d, k; cin >> r >> c >> d >> k;
char arr[r+1][c+1];
int pre[r+1][c+1];
memset(pre, 0, sizeof(pre));
for (int i=1; i<=r; i++) {
for (int j=1; j<=c; j++) {
cin >> arr[i][j];
if (arr[i][j] == 'S') pre[i][j] = 1;
else pre[i][j] = 0;
pre[i][j] = pre[i][j] + pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1];
}
}
ll 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 (pre[x2][y2] - pre[x1 - 1][y2] - pre[x2][y1 - 1] + pre[x1 - 1][y1 - 1] >= k) {
ans = ans + 1;
}
}
}
}
cout << ans;
return 0;
}
# | 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... |