Submission #1108449

#TimeUsernameProblemLanguageResultExecution timeMemory
1108449simona1230Circle selection (APIO18_circle_selection)C++17
7 / 100
3068 ms21320 KiB
#include <bits/stdc++.h> using namespace std; struct circle { long long x,y,r,i; circle(){} circle(long long _x,long long _y,long long _r,long long _i) { x=_x; y=_y; r=_r; i=_i; } }; long long n; circle a[200001]; bool cmp(circle c1,circle c2) { if(c1.r==c2.r)return c1.i<c2.i; return c1.r>c2.r; } void read() { cin>>n; for(long long i=1;i<=n;i++) { cin>>a[i].x>>a[i].y>>a[i].r; a[i].i=i; } sort(a+1,a+n+1,cmp); } long long used[200001]; bool intersect(circle c1,circle c2) { long long d1=(c1.x-c2.x)*(c1.x-c2.x)+(c1.y-c2.y)*(c1.y-c2.y); long long d2=(c1.r+c2.r)*(c1.r+c2.r); return d1<=d2; } void solve() { for(long long i=1;i<=n;i++) { if(used[a[i].i])continue; for(long long j=i;j<=n;j++) { if(used[a[j].i])continue; if(intersect(a[i],a[j])) used[a[j].i]=a[i].i; } } for(long long i=1;i<=n;i++) cout<<used[i]<<" "; cout<<endl; } int main() { read(); solve(); return 0; }
#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...