#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n,m,d,k,ans;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>d>>k;
string s[n];
for (int i=1; i<=n; ++i) {
cin>>s[i];
s[i]=" "+s[i];
}
int dp[n][m];
memset(dp,0,sizeof(dp));
for (int i=1; i<=n; ++i) {
for (int j=1; j<=m; ++j) {
dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
if (s[i][j]=='S') ++dp[i][j];
}
}
for (int i=1; i<=n; ++i) {
for (int j=1; j<=m; ++j) {
if (s[i][j]=='M') {
if (dp[min(i+d,n)][min(j+d,m)]-dp[min(i+d,n)][max(0,j-d-1)]-dp[max(0,i-d-1)][min(j+d,m)]+dp[max(0,i-d-1)][max(0,j-d-1)]>=k) ++ans;
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |