# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
921548 | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 2045 ms | 8388 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
using namespace std;
void solve(){
ll a,b,d,k;
cin>>a>>b>>d>>k;
char c[a+1][b+1];
vector<pair<ll,ll> >v,l;
for(ll i=1;i<=a;i++){
for(ll j=1;j<=b;j++){
cin>>c[i][j];
if(c[i][j]=='S'){
v.pb({i,j});
}
else if(c[i][j]=='M'){
l.pb({i,j});
}
}
}
ll ans=0,count=0;
for(ll i=0;i<l.size();i++){
ans=0;
for(ll j=0;j<v.size();j++){
ll res=0;
res=sqrt((v[j].first-l[i].first)*(v[j].first-l[i].first)+(v[j].second-l[i].second)*(v[j].second-l[i].second));
if(res<=d){
ans++;
}
if(ans==k){
count++;
break;
}
}
}
cout<<count;
}
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
ll t=1,i=1;
//cin>>t;
while(t--){
//cout<<"Case ";
//cout<<i<<':'<<"\n";
//i++;
solve();
}
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... |