#include <iostream>
#include <vector>
using namespace std;
vector <pair<int,int>> poz;
int main()
{
int n,m,k,nrmin,i,j,cnt=0;
char cha;
cin>>n>>m>>k>>nrmin;
int aux[n+2][m+2],sp[n+2][m+2];
for(i=0;i<=n+1;i++){for(j=0;j<=m+1;j++){aux[i][j]=sp[i][j]=0;}}
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
cin>>cha;
if(cha=='M'){
poz.push_back({i,j});
}else if(cha=='S'){
aux[max(i-k,1)][max(j-k,1)]++;
aux[max(i-k,1)][min(m+1,j+k+1)]--;
aux[min(n+1,i+k+1)][max(j-k,1)]--;
aux[min(n+1,i+k+1)][min(m+1,j+k+1)]++;
}
}
}
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
sp[i][j]=sp[i-1][j]+sp[i][j-1]-sp[i-1][j-1]+aux[i][j];
}
}
for(i=0;i<poz.size();i++){
pair <int,int> cord;
cord=poz[i];
if(sp[cord.first][cord.second]>=nrmin)
cnt++;
}
cout<<cnt;
return 0;
}
Compilation message
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(i=0;i<poz.size();i++){
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
596 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 |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2004 KB |
Output is correct |
3 |
Correct |
10 ms |
2516 KB |
Output is correct |
4 |
Correct |
8 ms |
2004 KB |
Output is correct |
5 |
Correct |
9 ms |
2232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
14536 KB |
Output is correct |
2 |
Correct |
26 ms |
16724 KB |
Output is correct |
3 |
Correct |
35 ms |
16684 KB |
Output is correct |
4 |
Correct |
28 ms |
14664 KB |
Output is correct |
5 |
Correct |
29 ms |
16700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
8 ms |
2004 KB |
Output is correct |
17 |
Correct |
8 ms |
2004 KB |
Output is correct |
18 |
Correct |
10 ms |
2516 KB |
Output is correct |
19 |
Correct |
8 ms |
2004 KB |
Output is correct |
20 |
Correct |
9 ms |
2232 KB |
Output is correct |
21 |
Correct |
27 ms |
14536 KB |
Output is correct |
22 |
Correct |
26 ms |
16724 KB |
Output is correct |
23 |
Correct |
35 ms |
16684 KB |
Output is correct |
24 |
Correct |
28 ms |
14664 KB |
Output is correct |
25 |
Correct |
29 ms |
16700 KB |
Output is correct |
26 |
Correct |
22 ms |
5908 KB |
Output is correct |
27 |
Correct |
23 ms |
6716 KB |
Output is correct |
28 |
Correct |
22 ms |
5836 KB |
Output is correct |
29 |
Correct |
22 ms |
5932 KB |
Output is correct |
30 |
Correct |
22 ms |
7000 KB |
Output is correct |