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 sz(x) (int)(x).size();
#define pii pair<ll,ll>
#define f first
#define s second
using namespace std;
ll sq(ll a)
{
return a*a;
}
int ans[5001];
pair<pii,pii> p[5000];
int main()
{
int n;
cin>>n;
for (int i=0;i<n;++i)
{
cin>>p[i].s.f>>p[i].s.s>>p[i].f.f;
p[i].f.s=-(i+1);
}
sort(p,p+n,greater<pair<pii,pii>>());
for (int i=0;i<n;++i)
{
if (ans[-(p[i].f.s)])
continue;
for (int j=i;j<n;++j)
if (!ans[-(p[j].f.s)])
if (sq(p[i].s.f-p[j].s.f)+sq(p[i].s.s-p[j].s.s)<=sq(p[i].f.f+p[j].f.f))
ans[-(p[j].f.s)]=-(p[i].f.s);
}
for (int i=1;i<=n;++i)
cout<<ans[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... |