#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(NULL)->sync_with_stdio(false);
int n,m,d,k; cin >> n >> m >> d >> k;
char mp[n+5][m+5];
int v[n+5][m+5],qs[n+d+5][m+d+5];
for(int i=0 ; i<=n ; i++){
for(int j=0 ; j<=m ; j++){
v[i][j]=0;
qs[i][j]=0;
}
}
int ans=0;
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=m ; j++){
cin >> mp[i][j];
}
}
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=m ; j++){
if(mp[i][j]=='S'){
v[max(1,i-d)][max(1,j-d)]++;
v[max(1,i-d)][j+d+1]--;
v[i+d+1][max(1,j-d)]--;
v[i+d+1][j+d+1]++;
}
}
}
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=m ; j++){
qs[i][j]=qs[i-1][j]+qs[i][j-1]-qs[i-1][j-1]+v[i][j];
}
}
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=m ; j++){
if(mp[i][j]=='M'){
if(qs[i][j]>=k) ans++;
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
8284 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
137 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |