#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#define double long double
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int r, c, d, k;
cin>>r>>c>>d>>k;
int arr[r+1][c+1];
bool mush[r+1][c+1];
for(int i = 0;i<=r;i++){
for(int j = 0;j<=c;j++){
arr[i][j] = 0;
mush[i][j] = false;
}
}
for(int i = 0;i<r;i++){
for(int j = 0;j<c;j++){
char s;
cin>>s;
if(s=='M') mush[i][j] = true;
else if(s=='S'){
int bottom = max(0, i-d);
int left = max(0, j-d);
int right = min(c-1, j+d);
int top = min(r-1, i+d);
//cout<<"("<<i<<", "<<j<<") "<<bottom<<left<<right<<top<<endl;
arr[bottom][left]++;
arr[bottom][right+1]--;
arr[top+1][left]--;
arr[top+1][right+1]++;
}
}
}
for(int i = 1;i<=r;i++){
arr[i][0]+=arr[i-1][0];
}
for(int i = 1;i<=c;i++){
arr[0][i]+=arr[0][i-1];
}
for(int i = 1;i<=r;i++){
for(int j = 1;j<=c;j++){
arr[i][j]-=arr[i-1][j-1];
arr[i][j]+=arr[i-1][j];
arr[i][j]+=arr[i][j-1];
}
}
int cnt = 0;
for(int i = 0;i<r;i++){
for(int j = 0;j<c;j++){
if(arr[i][j]>=k && mush[i][j]) cnt++;
}
}
cout<<cnt<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1532 KB |
Output is correct |
2 |
Correct |
8 ms |
1528 KB |
Output is correct |
3 |
Correct |
8 ms |
1784 KB |
Output is correct |
4 |
Correct |
9 ms |
1528 KB |
Output is correct |
5 |
Correct |
7 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
5752 KB |
Output is correct |
2 |
Correct |
19 ms |
5752 KB |
Output is correct |
3 |
Correct |
20 ms |
5752 KB |
Output is correct |
4 |
Correct |
23 ms |
5752 KB |
Output is correct |
5 |
Correct |
21 ms |
5752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
7 ms |
1532 KB |
Output is correct |
17 |
Correct |
8 ms |
1528 KB |
Output is correct |
18 |
Correct |
8 ms |
1784 KB |
Output is correct |
19 |
Correct |
9 ms |
1528 KB |
Output is correct |
20 |
Correct |
7 ms |
1656 KB |
Output is correct |
21 |
Correct |
52 ms |
5752 KB |
Output is correct |
22 |
Correct |
19 ms |
5752 KB |
Output is correct |
23 |
Correct |
20 ms |
5752 KB |
Output is correct |
24 |
Correct |
23 ms |
5752 KB |
Output is correct |
25 |
Correct |
21 ms |
5752 KB |
Output is correct |
26 |
Correct |
18 ms |
3320 KB |
Output is correct |
27 |
Correct |
17 ms |
3320 KB |
Output is correct |
28 |
Correct |
18 ms |
3320 KB |
Output is correct |
29 |
Correct |
17 ms |
3320 KB |
Output is correct |
30 |
Correct |
17 ms |
3320 KB |
Output is correct |