# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547792 | unicornboy | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 2072 ms | 3764 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>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int N=5e5+1;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
ll n , m , d , k;
cin >> n >> m >> d >> k ;
vector<pair<int,int>>mushrooms;
vector<pair<int,int>>sprinklers;
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
char c;
cin >> c ;
if(c=='M')
{
mushrooms.pb({i,j});
}
else if (c=='S')
{
sprinklers.pb({i,j});
}
}
}
// iterate on each sprinkler for each mushroom
int ans=0;
for (int i=0;i<mushrooms.size();i++)
{
int count=0;
for (int j=0;j<sprinklers.size();j++)
{
int dis=max(abs(sprinklers[j].ff-mushrooms[i].ff),abs(sprinklers[j].ss-mushrooms[i].ss));
if(dis<=d)
{
count++;
}
if(count>=k)
break;
}
if(count>=k)
ans++;
}
cout<<ans<<"\n";
}
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... |