#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=5*1e5+6;
const int mod= 998244353;
const ll inf=2*1e16+9;
int r,c,d,k;
char a[mx];
ll pref[mx];
int get(int i){
int sum=0;
int right=min(c-1,i+d);
int left=max(0,i-d);
sum=pref[right];
if(left==0){return sum;}return (sum-pref[left-1]);
}
int main() {
cin>>r>>c>>d>>k;
if(r==1){
ll ans=0;
for(int i=0;i<c;i++){
cin>>a[i];
if(a[i]=='S'){
pref[i]++;
}
if(i!=0){pref[i]+=pref[i-1];}
} for(int i=0;i<c;i++){
int sum=0;
if(a[i]=='M'){
sum=get(i);
}
if(sum>=k){ans++;}//
//cout<<pref[i];
}
cout<<ans;return 0;
}
if(d==max(r,c)){
int mushrom=0;int s=0;
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
char x;
cin>>x;
mushrom+=(x=='M');
s+=(x=='S');
}
}
if(s>=k){cout<<mushrom;}else{cout<<0;}
return 0;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
4708 KB |
Output is correct |
2 |
Correct |
35 ms |
4708 KB |
Output is correct |
3 |
Correct |
37 ms |
4836 KB |
Output is correct |
4 |
Correct |
36 ms |
4708 KB |
Output is correct |
5 |
Correct |
36 ms |
4708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |