#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 1000000000
#define N 300005
#define LOG 20
#define magic 100
#define KOK 350
#define EPS 0.0025
#define pw(x) ((1ll)<<(x))
#define PI 3.1415926535
#define dec fdefwe
using namespace std;
struct Circle {
int x,y,r,id;
};
int n,x,y,r,R;
Circle T[N],C[N];
int take[N],p[N];
vector< vector<Circle> > V;
lf dist(ii x,ii y) {
return sqrt(1ll*(x.st-y.st)*(x.st-y.st)+1ll*(x.nd-y.nd)*(x.nd-y.nd));
}
bool inter(Circle a,Circle b) {
if(dist({a.x,a.y},{b.x,b.y})<=a.r+b.r) return true;
return false;
}
void split() {
vector< vector< Circle> > New;
for(int i=0;i<sz(V);i++) {
vector<Circle> down,up;
int prvY=V[i][0].y-V[i][0].y%R+1;
int midY=prvY+R/2-1;
for(int j=0;j<sz(V[i]);j++) {
Circle Now=V[i][j];
if(Now.y<=midY) down.pb(Now);
else up.pb(Now);
}
if(sz(down)) New.pb(down);
if(sz(up)) New.pb(up);
}
V=New;
R/=2;
}
void up(int ind) {
while(T[ind].r<=R/2) {
split();
}
}
void solve(int now) {
int pos=lower_bound(all(V),T[now],[&](const vector<Circle> &Cc,const Circle &Now){
if(Cc[0].y<=Now.y-2*R-Now.y%R) return true;
return false;
})-V.begin();
for(int i=pos;i<sz(V);i++) {
if(V[i][0].y>T[now].y+3*R-T[now].y%R) break ;
int bas=lower_bound(all(V[i]),T[now],[&](const Circle &a,const Circle &b) {
if(a.x<=b.x-2*R-b.x%R) return true;
return false;
})-V[i].begin();
for(int j=bas;j<sz(V[i]);j++) {
Circle Now=V[i][j];
if(Now.x>T[now].x+3*R-T[now].y%R) break ;
if(!take[Now.id] && inter(Now,T[now])) {
take[Now.id]=1;
p[Now.id]=T[now].id;
}
}
}
}
void build() {
for(int i=1;i<=n;i++) {
int nxtY=R-C[i].y%R+C[i].y;
vector<Circle> Push;
while(i+1<=n && C[i+1].y<=nxtY) {
Push.pb(C[i]);
i++;
}
Push.pb(C[i]);
sort(all(Push),[](Circle a,Circle b) {
if(a.x<b.x) return true;
return false;
});
V.pb(Push);
}
}
int main() {
#if 0
freopen("input.txt","r",stdin);
#endif
scanf("%d",&n);
for(int i=1;i<=n;i++) {
scanf("%d %d %d",&x,&y,&r);
C[i]={x,y,r,i};
T[i]=C[i];
}
sort(C+1,C+1+n,[](Circle a,Circle b) {
if(a.y<b.y) return true;
if(a.y>b.y) return false;
if(a.x<b.x) return true;
return false;
});
sort(T+1,T+1+n,[](Circle a,Circle b) {
if(a.r>b.r) return true;
if(a.r<b.r) return false;
if(a.id<b.id) return true;
return false;
});
R=T[1].r;
build();
for(int i=1;i<=n;i++) {
if(!take[T[i].id]) {
up(i);
solve(i);
}
}
for(int i=1;i<=n;i++) printf("%d ",p[i]);
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:188:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
circle_selection.cpp:192:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&x,&y,&r);
~~~~~^~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
560 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
324 ms |
29896 KB |
Output is correct |
2 |
Correct |
297 ms |
29936 KB |
Output is correct |
3 |
Correct |
282 ms |
29936 KB |
Output is correct |
4 |
Incorrect |
396 ms |
30076 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
30076 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
443 ms |
30076 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
560 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
560 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |