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