#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 get(x,y) ((x<0)?(x+y):(x))
using namespace std;
struct Circle {
int x,y,r,id;
};
int n,x,y,r,R=pw(30);
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-get(V[i][0].y%R,R);
int midY=prvY+R/2-1;
for(int j=0;j<sz(V[i]);j++) {
Circle Now=V[i][j];
if(take[Now.id]) continue ;
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<1ll*Now.y-2ll*R-get(Now.y%R,R)) return true;
return false;
})-V.begin();
for(int i=pos;i<sz(V);i++) {
if(V[i][0].y>1ll*T[now].y+3ll*R-get(T[now].y%R,R)-1) break ;
int bas=lower_bound(all(V[i]),T[now],[&](const Circle &a,const Circle &b) {
if(a.x<1ll*b.x-2ll*R-get(b.x%R,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>1ll*T[now].x+3ll*R-get(T[now].y%R,R)-1) 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-get(C[i].y%R,R)+C[i].y-1;
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;
});
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:190:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
circle_selection.cpp:194: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);
~~~~~^~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
608 KB |
Output is correct |
5 |
Correct |
2 ms |
608 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
3 ms |
640 KB |
Output is correct |
14 |
Correct |
3 ms |
640 KB |
Output is correct |
15 |
Correct |
2 ms |
640 KB |
Output is correct |
16 |
Correct |
4 ms |
640 KB |
Output is correct |
17 |
Correct |
4 ms |
640 KB |
Output is correct |
18 |
Correct |
3 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
920 KB |
Output is correct |
20 |
Correct |
6 ms |
956 KB |
Output is correct |
21 |
Correct |
6 ms |
956 KB |
Output is correct |
22 |
Correct |
15 ms |
1552 KB |
Output is correct |
23 |
Correct |
17 ms |
1752 KB |
Output is correct |
24 |
Correct |
16 ms |
1752 KB |
Output is correct |
25 |
Correct |
16 ms |
1752 KB |
Output is correct |
26 |
Correct |
15 ms |
1752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
276 ms |
27592 KB |
Output is correct |
2 |
Correct |
289 ms |
27648 KB |
Output is correct |
3 |
Correct |
303 ms |
27648 KB |
Output is correct |
4 |
Correct |
263 ms |
27648 KB |
Output is correct |
5 |
Correct |
495 ms |
27864 KB |
Output is correct |
6 |
Correct |
544 ms |
27864 KB |
Output is correct |
7 |
Correct |
561 ms |
28016 KB |
Output is correct |
8 |
Correct |
511 ms |
28016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
28016 KB |
Output is correct |
2 |
Correct |
216 ms |
28016 KB |
Output is correct |
3 |
Correct |
730 ms |
28068 KB |
Output is correct |
4 |
Correct |
714 ms |
30244 KB |
Output is correct |
5 |
Correct |
577 ms |
30244 KB |
Output is correct |
6 |
Correct |
292 ms |
30244 KB |
Output is correct |
7 |
Correct |
144 ms |
30244 KB |
Output is correct |
8 |
Correct |
36 ms |
30244 KB |
Output is correct |
9 |
Correct |
715 ms |
30244 KB |
Output is correct |
10 |
Correct |
573 ms |
30244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
671 ms |
35856 KB |
Output is correct |
2 |
Correct |
1695 ms |
76032 KB |
Output is correct |
3 |
Correct |
403 ms |
76032 KB |
Output is correct |
4 |
Correct |
975 ms |
76032 KB |
Output is correct |
5 |
Correct |
868 ms |
76032 KB |
Output is correct |
6 |
Correct |
369 ms |
76032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
608 KB |
Output is correct |
5 |
Correct |
2 ms |
608 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
3 ms |
640 KB |
Output is correct |
14 |
Correct |
3 ms |
640 KB |
Output is correct |
15 |
Correct |
2 ms |
640 KB |
Output is correct |
16 |
Correct |
4 ms |
640 KB |
Output is correct |
17 |
Correct |
4 ms |
640 KB |
Output is correct |
18 |
Correct |
3 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
920 KB |
Output is correct |
20 |
Correct |
6 ms |
956 KB |
Output is correct |
21 |
Correct |
6 ms |
956 KB |
Output is correct |
22 |
Correct |
15 ms |
1552 KB |
Output is correct |
23 |
Correct |
17 ms |
1752 KB |
Output is correct |
24 |
Correct |
16 ms |
1752 KB |
Output is correct |
25 |
Correct |
16 ms |
1752 KB |
Output is correct |
26 |
Correct |
15 ms |
1752 KB |
Output is correct |
27 |
Correct |
11 ms |
76032 KB |
Output is correct |
28 |
Correct |
15 ms |
76032 KB |
Output is correct |
29 |
Correct |
14 ms |
76032 KB |
Output is correct |
30 |
Correct |
28 ms |
76032 KB |
Output is correct |
31 |
Correct |
25 ms |
76032 KB |
Output is correct |
32 |
Correct |
28 ms |
76032 KB |
Output is correct |
33 |
Correct |
146 ms |
76032 KB |
Output is correct |
34 |
Correct |
114 ms |
76032 KB |
Output is correct |
35 |
Correct |
113 ms |
76032 KB |
Output is correct |
36 |
Correct |
250 ms |
76032 KB |
Output is correct |
37 |
Correct |
254 ms |
76032 KB |
Output is correct |
38 |
Correct |
264 ms |
76032 KB |
Output is correct |
39 |
Correct |
225 ms |
76032 KB |
Output is correct |
40 |
Correct |
231 ms |
76032 KB |
Output is correct |
41 |
Correct |
242 ms |
76032 KB |
Output is correct |
42 |
Correct |
154 ms |
76032 KB |
Output is correct |
43 |
Correct |
247 ms |
76032 KB |
Output is correct |
44 |
Correct |
251 ms |
76032 KB |
Output is correct |
45 |
Correct |
263 ms |
76032 KB |
Output is correct |
46 |
Correct |
250 ms |
76032 KB |
Output is correct |
47 |
Correct |
253 ms |
76032 KB |
Output is correct |
48 |
Correct |
300 ms |
76032 KB |
Output is correct |
49 |
Correct |
251 ms |
76032 KB |
Output is correct |
50 |
Correct |
287 ms |
76032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
608 KB |
Output is correct |
5 |
Correct |
2 ms |
608 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
608 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
3 ms |
640 KB |
Output is correct |
14 |
Correct |
3 ms |
640 KB |
Output is correct |
15 |
Correct |
2 ms |
640 KB |
Output is correct |
16 |
Correct |
4 ms |
640 KB |
Output is correct |
17 |
Correct |
4 ms |
640 KB |
Output is correct |
18 |
Correct |
3 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
920 KB |
Output is correct |
20 |
Correct |
6 ms |
956 KB |
Output is correct |
21 |
Correct |
6 ms |
956 KB |
Output is correct |
22 |
Correct |
15 ms |
1552 KB |
Output is correct |
23 |
Correct |
17 ms |
1752 KB |
Output is correct |
24 |
Correct |
16 ms |
1752 KB |
Output is correct |
25 |
Correct |
16 ms |
1752 KB |
Output is correct |
26 |
Correct |
15 ms |
1752 KB |
Output is correct |
27 |
Correct |
276 ms |
27592 KB |
Output is correct |
28 |
Correct |
289 ms |
27648 KB |
Output is correct |
29 |
Correct |
303 ms |
27648 KB |
Output is correct |
30 |
Correct |
263 ms |
27648 KB |
Output is correct |
31 |
Correct |
495 ms |
27864 KB |
Output is correct |
32 |
Correct |
544 ms |
27864 KB |
Output is correct |
33 |
Correct |
561 ms |
28016 KB |
Output is correct |
34 |
Correct |
511 ms |
28016 KB |
Output is correct |
35 |
Correct |
2 ms |
28016 KB |
Output is correct |
36 |
Correct |
216 ms |
28016 KB |
Output is correct |
37 |
Correct |
730 ms |
28068 KB |
Output is correct |
38 |
Correct |
714 ms |
30244 KB |
Output is correct |
39 |
Correct |
577 ms |
30244 KB |
Output is correct |
40 |
Correct |
292 ms |
30244 KB |
Output is correct |
41 |
Correct |
144 ms |
30244 KB |
Output is correct |
42 |
Correct |
36 ms |
30244 KB |
Output is correct |
43 |
Correct |
715 ms |
30244 KB |
Output is correct |
44 |
Correct |
573 ms |
30244 KB |
Output is correct |
45 |
Correct |
671 ms |
35856 KB |
Output is correct |
46 |
Correct |
1695 ms |
76032 KB |
Output is correct |
47 |
Correct |
403 ms |
76032 KB |
Output is correct |
48 |
Correct |
975 ms |
76032 KB |
Output is correct |
49 |
Correct |
868 ms |
76032 KB |
Output is correct |
50 |
Correct |
369 ms |
76032 KB |
Output is correct |
51 |
Correct |
11 ms |
76032 KB |
Output is correct |
52 |
Correct |
15 ms |
76032 KB |
Output is correct |
53 |
Correct |
14 ms |
76032 KB |
Output is correct |
54 |
Correct |
28 ms |
76032 KB |
Output is correct |
55 |
Correct |
25 ms |
76032 KB |
Output is correct |
56 |
Correct |
28 ms |
76032 KB |
Output is correct |
57 |
Correct |
146 ms |
76032 KB |
Output is correct |
58 |
Correct |
114 ms |
76032 KB |
Output is correct |
59 |
Correct |
113 ms |
76032 KB |
Output is correct |
60 |
Correct |
250 ms |
76032 KB |
Output is correct |
61 |
Correct |
254 ms |
76032 KB |
Output is correct |
62 |
Correct |
264 ms |
76032 KB |
Output is correct |
63 |
Correct |
225 ms |
76032 KB |
Output is correct |
64 |
Correct |
231 ms |
76032 KB |
Output is correct |
65 |
Correct |
242 ms |
76032 KB |
Output is correct |
66 |
Correct |
154 ms |
76032 KB |
Output is correct |
67 |
Correct |
247 ms |
76032 KB |
Output is correct |
68 |
Correct |
251 ms |
76032 KB |
Output is correct |
69 |
Correct |
263 ms |
76032 KB |
Output is correct |
70 |
Correct |
250 ms |
76032 KB |
Output is correct |
71 |
Correct |
253 ms |
76032 KB |
Output is correct |
72 |
Correct |
300 ms |
76032 KB |
Output is correct |
73 |
Correct |
251 ms |
76032 KB |
Output is correct |
74 |
Correct |
287 ms |
76032 KB |
Output is correct |
75 |
Correct |
416 ms |
76032 KB |
Output is correct |
76 |
Correct |
392 ms |
76032 KB |
Output is correct |
77 |
Correct |
417 ms |
76032 KB |
Output is correct |
78 |
Correct |
317 ms |
76032 KB |
Output is correct |
79 |
Correct |
399 ms |
76032 KB |
Output is correct |
80 |
Correct |
317 ms |
76032 KB |
Output is correct |
81 |
Correct |
908 ms |
76032 KB |
Output is correct |
82 |
Correct |
727 ms |
76032 KB |
Output is correct |
83 |
Correct |
759 ms |
76032 KB |
Output is correct |
84 |
Correct |
817 ms |
76032 KB |
Output is correct |
85 |
Correct |
797 ms |
76032 KB |
Output is correct |
86 |
Correct |
757 ms |
76032 KB |
Output is correct |
87 |
Correct |
770 ms |
76032 KB |
Output is correct |
88 |
Correct |
796 ms |
76032 KB |
Output is correct |
89 |
Correct |
836 ms |
76032 KB |
Output is correct |
90 |
Correct |
895 ms |
76032 KB |
Output is correct |
91 |
Correct |
916 ms |
76032 KB |
Output is correct |
92 |
Correct |
1153 ms |
76032 KB |
Output is correct |
93 |
Correct |
872 ms |
76032 KB |
Output is correct |
94 |
Correct |
1273 ms |
76032 KB |
Output is correct |
95 |
Correct |
971 ms |
76032 KB |
Output is correct |
96 |
Correct |
1059 ms |
76032 KB |
Output is correct |
97 |
Correct |
1526 ms |
76032 KB |
Output is correct |
98 |
Correct |
619 ms |
76032 KB |
Output is correct |
99 |
Correct |
852 ms |
76032 KB |
Output is correct |
100 |
Correct |
879 ms |
76032 KB |
Output is correct |
101 |
Correct |
751 ms |
76032 KB |
Output is correct |
102 |
Correct |
968 ms |
76032 KB |
Output is correct |
103 |
Correct |
1136 ms |
76032 KB |
Output is correct |
104 |
Correct |
899 ms |
76032 KB |
Output is correct |
105 |
Correct |
525 ms |
76032 KB |
Output is correct |
106 |
Correct |
879 ms |
76032 KB |
Output is correct |
107 |
Correct |
876 ms |
76032 KB |
Output is correct |
108 |
Correct |
940 ms |
76032 KB |
Output is correct |
109 |
Correct |
868 ms |
76032 KB |
Output is correct |
110 |
Correct |
857 ms |
76032 KB |
Output is correct |
111 |
Correct |
963 ms |
76032 KB |
Output is correct |
112 |
Correct |
935 ms |
76032 KB |
Output is correct |
113 |
Correct |
832 ms |
76032 KB |
Output is correct |
114 |
Correct |
815 ms |
76032 KB |
Output is correct |
115 |
Correct |
820 ms |
76032 KB |
Output is correct |
116 |
Correct |
720 ms |
76032 KB |
Output is correct |