#include <bits/stdc++.h>
#define F first
#define S second
#define ent '\n'
//#define int long long
#define pb push_back
typedef long double ld;
typedef long long ll;
using namespace std;
const int maxn = 1e6+12;
const int T = 0;
const int mod = 1e9+7;
int n,m,k,x,y,l,r;
//int ñ[maxn],b[maxn],c[maxn],fact[maxn];
string s,d;
void solve(){
cin>>n>>m>>k>>x;
char a[n+2][m+2];
int pref[n+2][m+2];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
pref[i][j]=(a[i][j]=='S') + pref[i][j-1] + pref[i-1][j] - pref[i-1][j-1];
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='M'){
int l1=max(1,i-k), l2=max(1,j-k) , r1 = min(i+k,n), r2 = min(j+k,m);
int cal=pref[r1][r2]+pref[l1-1][l2-1]-(pref[r1][l2-1]+pref[l1-1][r2]);
if(cal>=x)ans++;
}
}
}
cout<<ans;
}
//BEKSULTAN TOP
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
if(T)cin>>t;
while(t--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
344 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 |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
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 |
Correct |
3 ms |
1368 KB |
Output is correct |
2 |
Correct |
3 ms |
1368 KB |
Output is correct |
3 |
Correct |
3 ms |
1624 KB |
Output is correct |
4 |
Correct |
3 ms |
1468 KB |
Output is correct |
5 |
Correct |
3 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
7772 KB |
Output is correct |
2 |
Correct |
10 ms |
7772 KB |
Output is correct |
3 |
Correct |
10 ms |
7756 KB |
Output is correct |
4 |
Correct |
10 ms |
8024 KB |
Output is correct |
5 |
Correct |
10 ms |
8024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
1368 KB |
Output is correct |
17 |
Correct |
3 ms |
1368 KB |
Output is correct |
18 |
Correct |
3 ms |
1624 KB |
Output is correct |
19 |
Correct |
3 ms |
1468 KB |
Output is correct |
20 |
Correct |
3 ms |
1372 KB |
Output is correct |
21 |
Correct |
10 ms |
7772 KB |
Output is correct |
22 |
Correct |
10 ms |
7772 KB |
Output is correct |
23 |
Correct |
10 ms |
7756 KB |
Output is correct |
24 |
Correct |
10 ms |
8024 KB |
Output is correct |
25 |
Correct |
10 ms |
8024 KB |
Output is correct |
26 |
Correct |
7 ms |
3416 KB |
Output is correct |
27 |
Correct |
7 ms |
3164 KB |
Output is correct |
28 |
Correct |
7 ms |
3360 KB |
Output is correct |
29 |
Correct |
7 ms |
3420 KB |
Output is correct |
30 |
Correct |
8 ms |
3364 KB |
Output is correct |