# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
263819 | T0p_ | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 45 ms | 16752 KiB |
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<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> mushroom;
int main()
{
int n, m, d, w;
scanf(" %d %d %d %d",&n,&m,&d,&w);
int qs[n+5][m+5];
memset(qs, 0, sizeof qs);
for(int i=1 ; i<=n ; i++)
for(int j=1 ; j<=m ; j++)
{
char c;
scanf(" %c",&c);
if(c == 'M') mushroom.push_back({i, j});
else if(c == 'S')
{
int si = max(1, i-d), sj = max(1, j-d), ei = min(n, i+d), ej = min(m, j+d);
qs[si][sj]++;
qs[si][ej+1]--;
qs[ei+1][sj]--;
qs[ei+1][ej+1]++;
}
}
for(int i=1 ; i<=n ; i++)
for(int j=1 ; j<=m ; j++)
qs[i][j] += qs[i-1][j] + qs[i][j-1] - qs[i-1][j-1];
int ans = 0;
for(auto x : mushroom)
if(qs[x.first][x.second] >= w) ans++;
printf("%d\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |