#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
int R,C,K,D;
vector<vector<int>> arr,mush;
vector<string> v;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>R>>C>>D>>K;
arr = mush = vector<vector<int>>(R+1,vector<int>(C+1,0));
v = vector<string>(R+1);
for(int i = 0;i<R;i++){
cin>>v[i];
for(int j = 0;j<C;j++){
if(v[i][j] == 'S'){
int rl = i-D,rr = i+D+1;
int cl = j-D,cr = j+D+1;
cl = max(0,cl),cr = min(cr,C);
rl = max(0,rl),rr = min(rr,R);
arr[rl][cl]++,arr[rl][cr]--;
arr[rr][cl]--,arr[rr][cr]++;
}
else if(v[i][j] == 'M'){
mush[i][j] = 1;
}
}
}
int ans = 0;
vector<int> now(C+1,0);
for(int i = 0;i<R;i++){
int pref = 0;
for(int j = 0;j<=C;j++){
pref += arr[i][j];
now[j] += pref;
ans += (mush[i][j])*(now[j]>=K);
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
572 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2392 KB |
Output is correct |
2 |
Correct |
3 ms |
2512 KB |
Output is correct |
3 |
Correct |
2 ms |
2904 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
11704 KB |
Output is correct |
2 |
Correct |
7 ms |
11704 KB |
Output is correct |
3 |
Correct |
8 ms |
11724 KB |
Output is correct |
4 |
Correct |
9 ms |
11520 KB |
Output is correct |
5 |
Correct |
7 ms |
11724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
572 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
2392 KB |
Output is correct |
17 |
Correct |
3 ms |
2512 KB |
Output is correct |
18 |
Correct |
2 ms |
2904 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
2 ms |
2648 KB |
Output is correct |
21 |
Correct |
8 ms |
11704 KB |
Output is correct |
22 |
Correct |
7 ms |
11704 KB |
Output is correct |
23 |
Correct |
8 ms |
11724 KB |
Output is correct |
24 |
Correct |
9 ms |
11520 KB |
Output is correct |
25 |
Correct |
7 ms |
11724 KB |
Output is correct |
26 |
Correct |
11 ms |
8284 KB |
Output is correct |
27 |
Correct |
4 ms |
5260 KB |
Output is correct |
28 |
Correct |
5 ms |
5468 KB |
Output is correct |
29 |
Correct |
4 ms |
5720 KB |
Output is correct |
30 |
Correct |
8 ms |
7260 KB |
Output is correct |