#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int R, C, D, K;
cin >> R >> C >> D >> K;
string S[1+R];
for(int i = 1; i <= R; i++)
{
cin >> S[i];
S[i] = " " + S[i];
}
vvi delta(1+R+1, vi(1+C+1, 0));
for(int i = 1; i <= R; i++)
{
for(int j = 1; j <= C; j++)
{
if(S[i][j] != 'S') continue;
int i_lo = max(1, i - D);
int j_lo = max(1, j - D);
int i_hi = min(R, i + D);
int j_hi = min(C, j + D);
delta[i_lo][j_lo]++;
delta[i_hi+1][j_hi+1]++;
delta[i_lo][j_hi+1]--;
delta[i_hi+1][j_lo]--;
}
}
int ans = 0;
vvi tot(1+R+1, vi(1+C+1, 0));
for(int i = 1; i <= R; i++)
{
for(int j = 1; j <= C; j++)
{
tot[i][j] = tot[i][j-1] + tot[i-1][j] - tot[i-1][j-1] + delta[i][j];
if(tot[i][j] >= K && S[i][j] == 'M') ans++;
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1996 KB |
Output is correct |
2 |
Correct |
3 ms |
2372 KB |
Output is correct |
3 |
Correct |
4 ms |
2764 KB |
Output is correct |
4 |
Correct |
3 ms |
2380 KB |
Output is correct |
5 |
Correct |
3 ms |
2508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
14544 KB |
Output is correct |
2 |
Correct |
10 ms |
14928 KB |
Output is correct |
3 |
Correct |
10 ms |
14928 KB |
Output is correct |
4 |
Correct |
13 ms |
15020 KB |
Output is correct |
5 |
Correct |
11 ms |
14928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
1996 KB |
Output is correct |
17 |
Correct |
3 ms |
2372 KB |
Output is correct |
18 |
Correct |
4 ms |
2764 KB |
Output is correct |
19 |
Correct |
3 ms |
2380 KB |
Output is correct |
20 |
Correct |
3 ms |
2508 KB |
Output is correct |
21 |
Correct |
11 ms |
14544 KB |
Output is correct |
22 |
Correct |
10 ms |
14928 KB |
Output is correct |
23 |
Correct |
10 ms |
14928 KB |
Output is correct |
24 |
Correct |
13 ms |
15020 KB |
Output is correct |
25 |
Correct |
11 ms |
14928 KB |
Output is correct |
26 |
Correct |
16 ms |
8268 KB |
Output is correct |
27 |
Correct |
7 ms |
5196 KB |
Output is correct |
28 |
Correct |
8 ms |
5504 KB |
Output is correct |
29 |
Correct |
6 ms |
5324 KB |
Output is correct |
30 |
Correct |
10 ms |
7116 KB |
Output is correct |