This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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++){
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |