#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1236 KB |
Output is correct |
2 |
Correct |
4 ms |
1512 KB |
Output is correct |
3 |
Correct |
6 ms |
1788 KB |
Output is correct |
4 |
Correct |
4 ms |
1436 KB |
Output is correct |
5 |
Correct |
5 ms |
1512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
5620 KB |
Output is correct |
2 |
Correct |
12 ms |
5580 KB |
Output is correct |
3 |
Correct |
12 ms |
5588 KB |
Output is correct |
4 |
Correct |
12 ms |
5588 KB |
Output is correct |
5 |
Correct |
13 ms |
5696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
1236 KB |
Output is correct |
17 |
Correct |
4 ms |
1512 KB |
Output is correct |
18 |
Correct |
6 ms |
1788 KB |
Output is correct |
19 |
Correct |
4 ms |
1436 KB |
Output is correct |
20 |
Correct |
5 ms |
1512 KB |
Output is correct |
21 |
Correct |
13 ms |
5620 KB |
Output is correct |
22 |
Correct |
12 ms |
5580 KB |
Output is correct |
23 |
Correct |
12 ms |
5588 KB |
Output is correct |
24 |
Correct |
12 ms |
5588 KB |
Output is correct |
25 |
Correct |
13 ms |
5696 KB |
Output is correct |
26 |
Correct |
12 ms |
3144 KB |
Output is correct |
27 |
Correct |
11 ms |
3156 KB |
Output is correct |
28 |
Correct |
10 ms |
3148 KB |
Output is correct |
29 |
Correct |
11 ms |
3316 KB |
Output is correct |
30 |
Correct |
10 ms |
3280 KB |
Output is correct |