이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define LIFESUCKS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define ar array
#define vt vector
#define pb push_back
//ifstream fin("TAITRONG.INP");
//ofstream fout("TAITRONG.OUT");
#define fi first
#define se second
#define db double
#define ldb long double
#define vt vector
using namespace std;
int main()
{
LIFESUCKS;
int n, m, d, c; cin >> n >> m >> d >> c;
char a[n + 1][m + 1];
int pref[n + 1][m + 1];
memset(pref, 0, sizeof(pref));
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + (a[i][j] == 'S');
}
}
int res = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(a[i][j] == 'M'){
int cri = max(i - d, 1), crj = max(j - d, 1), lsi = min(i + d, n), lsj = min(j + d, m);
int cr = pref[lsi][lsj] - pref[lsi][crj - 1] - pref[cri - 1][lsj] + pref[cri - 1][crj - 1];
res += (cr >= c);
}
}
}
cout << res;
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... |