#include <bits/stdc++.h>
using namespace std;
#define i128 __int128
#define ll long long
#define ff first
#define ss second
#define pll pair<ll, ll>
#define pb push_back
#define elif else if
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const ll MOD = 1e9+7;
const ll base = 1e18;
const ll maxn = 5e5+5;
ll p[maxn];
int main(){
fast_io;
ll r,c,d,k;
cin>>r>>c>>d>>k;
vector<vector<char>> a(r, vector<char> (c));
for (int i=0;i<c;i++){
cin>>a[0][i];
//cout<<a[0][i]<<endl;
if (a[0][i]=='S'){
//range
ll start = max(0ll, i - d);
ll end = min(c-1,i + d);
p[start]=p[start]+1;
p[end+1]=p[end+1]-1;
//cout<<start<<" "<<end<<endl;
//the range of the boundary is 0->c-1
}
}
for (int i=1;i<c;i++){
p[i]=p[i]+p[i-1];
}
ll ans=0;
for (int i=0;i<c;i++){
if (a[0][i]=='M'&&p[i]>=k){
ans++;
}
//cout<<p[i]<<endl;
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
5220 KB |
Output is correct |
2 |
Correct |
9 ms |
5220 KB |
Output is correct |
3 |
Correct |
9 ms |
5220 KB |
Output is correct |
4 |
Correct |
12 ms |
5220 KB |
Output is correct |
5 |
Correct |
10 ms |
5232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |