#include<bits/stdc++.h>
using namespace std;
const int mxN = 500 + 5;
char grid[mxN][mxN];
int cnt[mxN][mxN];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, d, k;
cin >> n >> m >> d >> k;
for(int i = 0;i < n;++i){
for(int j = 0;j < m;++j){
cin >> grid[i][j];
if(grid[i][j] == 'S'){
int x = max(i - d, 0);
int y = max(j - d, 0);
int x_end = min(i + d, n - 1);
int y_end = min(j + d, m - 1);
for(int i = x;i <= x_end;++i){
cnt[i][y] = 1;
cnt[i][y_end + 1] = -1;
}
}
}
}
int res = 0;
for(int i = 0;i < n;++i){
int sum = 0;
for(int j = 0;j < m;++j){
sum += cnt[i][j];
if(grid[i][j] == 'M' && sum >= k){
res++;
}
}
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
728 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
728 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1628 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
728 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |