Submission #203724

#TimeUsernameProblemLanguageResultExecution timeMemory
203724SegtreeCircle selection (APIO18_circle_selection)C++14
7 / 100
85 ms1528 KiB
#include<iostream> #include<algorithm> #include<vector> #include<set> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define rep(i,n) for(int i=0;i<n;i++) #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define N 5010 ll n,x[N],y[N],r[N]; struct en{ ll rad,id; bool operator<(const en&key)const{ if(this->rad==key.rad)return this->id<key.id; return this->rad>key.rad; } }; ll par[N]; int main(){ cin>>n; vector<en> v; rep(i,n){ cin>>x[i]>>y[i]>>r[i]; v.push_back((struct en){r[i],i}); } sort(v.begin(),v.end()); rep(i,n)par[i]=-1; for(auto e:v){ if(par[e.id]>=0)continue; rep(i,n)if(par[i]==-1){ ll dx=x[i]-x[e.id]; dx*=dx; ll dy=y[i]-y[e.id]; dy*=dy; ll dr=r[i]+r[e.id]; dr*=dr; if(dx+dy<=dr)par[i]=e.id; } } rep(i,n)cout<<par[i]+1<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...