#include <cstdio>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
int n,m,k,r,i,j,l,d;
vector<int> v[500005];
vector<ii> memo;
char c;
int sum(int i1,int i2, int j1,int j2){
return (v[i2][j2]-v[i1][j2]-v[i2][j1]+v[i1][j1]);
}
int main(){
scanf("%d%d%d%d",&n,&m,&r,&k);
for(int x=0;x<=n;x++){
v[x].push_back(0);
}
for (int x=0;x<m;x++){
v[0].push_back(0);
}
for (int x=1;x<=n;x++){
getchar();
for (int y=1;y<=m;y++){
c=getchar();
i=v[x-1][y]+v[x][y-1]-v[x-1][y-1];
if (c=='S') i++;
else if(c=='M') memo.push_back(ii (x,y));
v[x].push_back(i);
}
}
/*for (int x=0;x<=n;x++){
for (int y=0;y<=m;y++){
printf("%d ",v[x][y]);
}
printf("\n");
}*/
l=memo.size();
for (int x=0;x<l;x++){
i=memo[x].first,j=memo[x].second;
if (sum(max(0,i-r-1),min(n,i+r),max(0,j-r-1),min(m,j+r))>=k) d++;
}
printf("%d\n",d);
}
Compilation message
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d%d%d%d",&n,&m,&r,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
11980 KB |
Output is correct |
2 |
Correct |
10 ms |
12108 KB |
Output is correct |
3 |
Correct |
10 ms |
12060 KB |
Output is correct |
4 |
Correct |
7 ms |
11980 KB |
Output is correct |
5 |
Correct |
9 ms |
11980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
11980 KB |
Output is correct |
2 |
Correct |
10 ms |
12108 KB |
Output is correct |
3 |
Correct |
10 ms |
12060 KB |
Output is correct |
4 |
Correct |
7 ms |
11980 KB |
Output is correct |
5 |
Correct |
9 ms |
11980 KB |
Output is correct |
6 |
Correct |
8 ms |
11952 KB |
Output is correct |
7 |
Correct |
8 ms |
12040 KB |
Output is correct |
8 |
Correct |
7 ms |
12024 KB |
Output is correct |
9 |
Correct |
8 ms |
11980 KB |
Output is correct |
10 |
Correct |
9 ms |
12024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
12024 KB |
Output is correct |
2 |
Correct |
9 ms |
11980 KB |
Output is correct |
3 |
Correct |
8 ms |
12236 KB |
Output is correct |
4 |
Correct |
10 ms |
11956 KB |
Output is correct |
5 |
Correct |
9 ms |
12028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
13004 KB |
Output is correct |
2 |
Correct |
10 ms |
13128 KB |
Output is correct |
3 |
Correct |
10 ms |
13260 KB |
Output is correct |
4 |
Correct |
12 ms |
13004 KB |
Output is correct |
5 |
Correct |
13 ms |
13136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
19072 KB |
Output is correct |
2 |
Correct |
25 ms |
22024 KB |
Output is correct |
3 |
Correct |
24 ms |
21924 KB |
Output is correct |
4 |
Correct |
21 ms |
19644 KB |
Output is correct |
5 |
Correct |
25 ms |
22028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
11980 KB |
Output is correct |
2 |
Correct |
10 ms |
12108 KB |
Output is correct |
3 |
Correct |
10 ms |
12060 KB |
Output is correct |
4 |
Correct |
7 ms |
11980 KB |
Output is correct |
5 |
Correct |
9 ms |
11980 KB |
Output is correct |
6 |
Correct |
8 ms |
11952 KB |
Output is correct |
7 |
Correct |
8 ms |
12040 KB |
Output is correct |
8 |
Correct |
7 ms |
12024 KB |
Output is correct |
9 |
Correct |
8 ms |
11980 KB |
Output is correct |
10 |
Correct |
9 ms |
12024 KB |
Output is correct |
11 |
Correct |
9 ms |
12024 KB |
Output is correct |
12 |
Correct |
9 ms |
11980 KB |
Output is correct |
13 |
Correct |
8 ms |
12236 KB |
Output is correct |
14 |
Correct |
10 ms |
11956 KB |
Output is correct |
15 |
Correct |
9 ms |
12028 KB |
Output is correct |
16 |
Correct |
9 ms |
13004 KB |
Output is correct |
17 |
Correct |
10 ms |
13128 KB |
Output is correct |
18 |
Correct |
10 ms |
13260 KB |
Output is correct |
19 |
Correct |
12 ms |
13004 KB |
Output is correct |
20 |
Correct |
13 ms |
13136 KB |
Output is correct |
21 |
Correct |
22 ms |
19072 KB |
Output is correct |
22 |
Correct |
25 ms |
22024 KB |
Output is correct |
23 |
Correct |
24 ms |
21924 KB |
Output is correct |
24 |
Correct |
21 ms |
19644 KB |
Output is correct |
25 |
Correct |
25 ms |
22028 KB |
Output is correct |
26 |
Correct |
22 ms |
16904 KB |
Output is correct |
27 |
Correct |
20 ms |
17084 KB |
Output is correct |
28 |
Correct |
17 ms |
15480 KB |
Output is correct |
29 |
Correct |
17 ms |
15684 KB |
Output is correct |
30 |
Correct |
20 ms |
16544 KB |
Output is correct |