#include <bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define pb push_back
#define task "hetcuu"
using namespace std;
using ll = long long;
using ld = long double;
const ll maxN = 100;
int r,c,d,k,ans = 0;
char a[maxN][maxN];
int pre[maxN][maxN];
int get(int i,int j){
return pre[i][j] + pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1];
}
int main(){
cin >> r >> c >> d >> k;
for(int i = 1; i <= r; i++){
for(int j = 1;j <=c;++j){
cin >> a[i][j];
}
}
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(a[i][j] == 'S'){
int ra = max(1,i-d);
int ca = max(1,j-d);
int rb = min(r,i+d);
int cb = min(c,j+d);
pre[ra][ca]++;
pre[ra][cb+1]--;
pre[rb+1][ca]--;
pre[rb+1][cb+1]++;
}
}
}
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
pre[i][j] = get(i,j);
}
}
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(pre[i][j] >= k && a[i][j] == 'M')ans++;
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2024 ms |
348 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2024 ms |
348 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
436 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2085 ms |
348 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2024 ms |
348 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |