#include<bits/stdc++.h>
using namespace std;
int n,m,a1,b1,a2,b2,d,k;
int main()
{
scanf("%d%d%d%d",&n,&m,&d,&k);
char s[n+5][m+5];
int sweep[n+5][m+5];
memset(sweep,0,sizeof sweep);
for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
//printf("%c",s[i][j]);
if(s[i][j]=='S')
{
a1=max(1,i-d),b1=max(1,j-d);
a2=min(n+1,i+d+1),b2=min(m+1,j+d+1);
//printf("%d %d %d %d\n",a1,b1,a2,b2);
sweep[a1][b1]+=1;
sweep[a1][b2]-=1,sweep[a2][b1]-=1,sweep[a2][b2]+=1;
}
}
//printf("\n");
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
sweep[i][j]=sweep[i][j]+sweep[i-1][j]+sweep[i][j-1]-sweep[i-1][j-1];
if(sweep[i][j]>=k&&s[i][j]=='M')++ans;
//printf("%d ",sweep[i][j]);
}
// printf("\n");
}
printf("%d\n",ans);
}
Compilation message
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
7 | scanf("%d%d%d%d",&n,&m,&d,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
| ~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1364 KB |
Output is correct |
2 |
Correct |
3 ms |
1580 KB |
Output is correct |
3 |
Correct |
4 ms |
1788 KB |
Output is correct |
4 |
Correct |
3 ms |
1492 KB |
Output is correct |
5 |
Correct |
4 ms |
1608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
15468 KB |
Output is correct |
2 |
Correct |
12 ms |
15444 KB |
Output is correct |
3 |
Correct |
12 ms |
15444 KB |
Output is correct |
4 |
Correct |
17 ms |
15564 KB |
Output is correct |
5 |
Correct |
13 ms |
15420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1364 KB |
Output is correct |
17 |
Correct |
3 ms |
1580 KB |
Output is correct |
18 |
Correct |
4 ms |
1788 KB |
Output is correct |
19 |
Correct |
3 ms |
1492 KB |
Output is correct |
20 |
Correct |
4 ms |
1608 KB |
Output is correct |
21 |
Correct |
13 ms |
15468 KB |
Output is correct |
22 |
Correct |
12 ms |
15444 KB |
Output is correct |
23 |
Correct |
12 ms |
15444 KB |
Output is correct |
24 |
Correct |
17 ms |
15564 KB |
Output is correct |
25 |
Correct |
13 ms |
15420 KB |
Output is correct |
26 |
Correct |
8 ms |
3644 KB |
Output is correct |
27 |
Correct |
6 ms |
3284 KB |
Output is correct |
28 |
Correct |
8 ms |
3528 KB |
Output is correct |
29 |
Correct |
7 ms |
3480 KB |
Output is correct |
30 |
Correct |
8 ms |
3516 KB |
Output is correct |