#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
const int offs = 1e9 + 100;
using pi = pair<int, int>;
struct circ{
int x, y, r, idx;
bool operator<(const circ &c)const{
return pi(x, y) < pi(c.x, c.y);
}
}a[MAXN], orig_pos[MAXN];
int n, ans[MAXN];
int main(){
scanf("%d",&n);
for(int i=0; i<n; i++){
scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].r);
a[i].x += offs;
a[i].y += offs;
a[i].idx = i + 1;
orig_pos[i + 1] = a[i];
}
auto inter = [&](circ a, circ b){
int dx = a.x - b.x;
int dy = a.y - b.y;
int dr = a.r + b.r;
return 1ll * dx * dx + 1ll * dy * dy <= 1ll * dr * dr;
};
sort(a, a+n, [&](const circ &a, const circ &b){
return pi(-a.r, a.idx) < pi(-b.r, b.idx);
});
for(int i=30; i; i--){
int lb = (1 << (i - 1)), rb = (1 << i) - 1;
vector<circ> v;
for(int j=0; j<n; j++){
if(!ans[a[j].idx] && a[j].r <= rb){
v.push_back((circ){a[j].x >> i, a[j].y >> i, a[j].r, a[j].idx});
}
}
sort(v.begin(), v.end());
for(int j=0; j<n; j++){
if(!ans[a[j].idx] && a[j].r <= rb && a[j].r >= lb){
for(int k=-2; k<=2; k++){
int px = (a[j].x >> i) + k;
int py = (a[j].y >> i) - 2;
auto itr = lower_bound(v.begin(), v.end(), (circ){px, py, -1, -1}) - v.begin();
while(itr < v.size() && pi(v[itr].x, v[itr].y) <= pi(px, py + 4)){
if(inter(orig_pos[v[itr].idx], a[j])){
if(!ans[v[itr].idx]) ans[v[itr].idx] = a[j].idx;
}
itr++;
}
}
}
}
}
for(int i=1; i<=n; i++) printf("%d ", ans[i]);
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(itr < v.size() && pi(v[itr].x, v[itr].y) <= pi(px, py + 4)){
~~~~^~~~~~~~~~
circle_selection.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
circle_selection.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].r);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
2 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
2 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
736 KB |
Output is correct |
14 |
Correct |
3 ms |
744 KB |
Output is correct |
15 |
Correct |
3 ms |
744 KB |
Output is correct |
16 |
Correct |
3 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
744 KB |
Output is correct |
18 |
Correct |
3 ms |
744 KB |
Output is correct |
19 |
Correct |
7 ms |
1020 KB |
Output is correct |
20 |
Correct |
6 ms |
1020 KB |
Output is correct |
21 |
Correct |
6 ms |
1036 KB |
Output is correct |
22 |
Correct |
18 ms |
1036 KB |
Output is correct |
23 |
Correct |
17 ms |
1040 KB |
Output is correct |
24 |
Correct |
18 ms |
1040 KB |
Output is correct |
25 |
Correct |
19 ms |
1132 KB |
Output is correct |
26 |
Correct |
17 ms |
1132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
291 ms |
24112 KB |
Output is correct |
2 |
Correct |
341 ms |
24268 KB |
Output is correct |
3 |
Correct |
340 ms |
24268 KB |
Output is correct |
4 |
Correct |
310 ms |
24268 KB |
Output is correct |
5 |
Correct |
908 ms |
24272 KB |
Output is correct |
6 |
Correct |
1101 ms |
24272 KB |
Output is correct |
7 |
Correct |
1008 ms |
24272 KB |
Output is correct |
8 |
Correct |
984 ms |
24272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
24272 KB |
Output is correct |
2 |
Correct |
366 ms |
24272 KB |
Output is correct |
3 |
Correct |
1241 ms |
24344 KB |
Output is correct |
4 |
Correct |
1198 ms |
24344 KB |
Output is correct |
5 |
Correct |
1080 ms |
24344 KB |
Output is correct |
6 |
Correct |
551 ms |
24344 KB |
Output is correct |
7 |
Correct |
243 ms |
24344 KB |
Output is correct |
8 |
Correct |
53 ms |
24344 KB |
Output is correct |
9 |
Correct |
1166 ms |
24344 KB |
Output is correct |
10 |
Correct |
943 ms |
24344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1357 ms |
24344 KB |
Output is correct |
2 |
Correct |
1852 ms |
24344 KB |
Output is correct |
3 |
Correct |
607 ms |
24344 KB |
Output is correct |
4 |
Correct |
1340 ms |
24356 KB |
Output is correct |
5 |
Correct |
1350 ms |
24356 KB |
Output is correct |
6 |
Correct |
501 ms |
24356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
2 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
2 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
736 KB |
Output is correct |
14 |
Correct |
3 ms |
744 KB |
Output is correct |
15 |
Correct |
3 ms |
744 KB |
Output is correct |
16 |
Correct |
3 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
744 KB |
Output is correct |
18 |
Correct |
3 ms |
744 KB |
Output is correct |
19 |
Correct |
7 ms |
1020 KB |
Output is correct |
20 |
Correct |
6 ms |
1020 KB |
Output is correct |
21 |
Correct |
6 ms |
1036 KB |
Output is correct |
22 |
Correct |
18 ms |
1036 KB |
Output is correct |
23 |
Correct |
17 ms |
1040 KB |
Output is correct |
24 |
Correct |
18 ms |
1040 KB |
Output is correct |
25 |
Correct |
19 ms |
1132 KB |
Output is correct |
26 |
Correct |
17 ms |
1132 KB |
Output is correct |
27 |
Correct |
13 ms |
24356 KB |
Output is correct |
28 |
Correct |
13 ms |
24356 KB |
Output is correct |
29 |
Correct |
12 ms |
24356 KB |
Output is correct |
30 |
Correct |
38 ms |
24356 KB |
Output is correct |
31 |
Correct |
36 ms |
24356 KB |
Output is correct |
32 |
Correct |
35 ms |
24356 KB |
Output is correct |
33 |
Correct |
107 ms |
24356 KB |
Output is correct |
34 |
Correct |
115 ms |
24356 KB |
Output is correct |
35 |
Correct |
155 ms |
24356 KB |
Output is correct |
36 |
Correct |
425 ms |
24356 KB |
Output is correct |
37 |
Correct |
396 ms |
24356 KB |
Output is correct |
38 |
Correct |
390 ms |
24356 KB |
Output is correct |
39 |
Correct |
428 ms |
24356 KB |
Output is correct |
40 |
Correct |
476 ms |
24356 KB |
Output is correct |
41 |
Correct |
380 ms |
24356 KB |
Output is correct |
42 |
Correct |
289 ms |
24356 KB |
Output is correct |
43 |
Correct |
377 ms |
24356 KB |
Output is correct |
44 |
Correct |
392 ms |
24356 KB |
Output is correct |
45 |
Correct |
365 ms |
24356 KB |
Output is correct |
46 |
Correct |
361 ms |
24356 KB |
Output is correct |
47 |
Correct |
355 ms |
24356 KB |
Output is correct |
48 |
Correct |
367 ms |
24356 KB |
Output is correct |
49 |
Correct |
359 ms |
24356 KB |
Output is correct |
50 |
Correct |
359 ms |
24356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
2 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
2 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
736 KB |
Output is correct |
14 |
Correct |
3 ms |
744 KB |
Output is correct |
15 |
Correct |
3 ms |
744 KB |
Output is correct |
16 |
Correct |
3 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
744 KB |
Output is correct |
18 |
Correct |
3 ms |
744 KB |
Output is correct |
19 |
Correct |
7 ms |
1020 KB |
Output is correct |
20 |
Correct |
6 ms |
1020 KB |
Output is correct |
21 |
Correct |
6 ms |
1036 KB |
Output is correct |
22 |
Correct |
18 ms |
1036 KB |
Output is correct |
23 |
Correct |
17 ms |
1040 KB |
Output is correct |
24 |
Correct |
18 ms |
1040 KB |
Output is correct |
25 |
Correct |
19 ms |
1132 KB |
Output is correct |
26 |
Correct |
17 ms |
1132 KB |
Output is correct |
27 |
Correct |
291 ms |
24112 KB |
Output is correct |
28 |
Correct |
341 ms |
24268 KB |
Output is correct |
29 |
Correct |
340 ms |
24268 KB |
Output is correct |
30 |
Correct |
310 ms |
24268 KB |
Output is correct |
31 |
Correct |
908 ms |
24272 KB |
Output is correct |
32 |
Correct |
1101 ms |
24272 KB |
Output is correct |
33 |
Correct |
1008 ms |
24272 KB |
Output is correct |
34 |
Correct |
984 ms |
24272 KB |
Output is correct |
35 |
Correct |
2 ms |
24272 KB |
Output is correct |
36 |
Correct |
366 ms |
24272 KB |
Output is correct |
37 |
Correct |
1241 ms |
24344 KB |
Output is correct |
38 |
Correct |
1198 ms |
24344 KB |
Output is correct |
39 |
Correct |
1080 ms |
24344 KB |
Output is correct |
40 |
Correct |
551 ms |
24344 KB |
Output is correct |
41 |
Correct |
243 ms |
24344 KB |
Output is correct |
42 |
Correct |
53 ms |
24344 KB |
Output is correct |
43 |
Correct |
1166 ms |
24344 KB |
Output is correct |
44 |
Correct |
943 ms |
24344 KB |
Output is correct |
45 |
Correct |
1357 ms |
24344 KB |
Output is correct |
46 |
Correct |
1852 ms |
24344 KB |
Output is correct |
47 |
Correct |
607 ms |
24344 KB |
Output is correct |
48 |
Correct |
1340 ms |
24356 KB |
Output is correct |
49 |
Correct |
1350 ms |
24356 KB |
Output is correct |
50 |
Correct |
501 ms |
24356 KB |
Output is correct |
51 |
Correct |
13 ms |
24356 KB |
Output is correct |
52 |
Correct |
13 ms |
24356 KB |
Output is correct |
53 |
Correct |
12 ms |
24356 KB |
Output is correct |
54 |
Correct |
38 ms |
24356 KB |
Output is correct |
55 |
Correct |
36 ms |
24356 KB |
Output is correct |
56 |
Correct |
35 ms |
24356 KB |
Output is correct |
57 |
Correct |
107 ms |
24356 KB |
Output is correct |
58 |
Correct |
115 ms |
24356 KB |
Output is correct |
59 |
Correct |
155 ms |
24356 KB |
Output is correct |
60 |
Correct |
425 ms |
24356 KB |
Output is correct |
61 |
Correct |
396 ms |
24356 KB |
Output is correct |
62 |
Correct |
390 ms |
24356 KB |
Output is correct |
63 |
Correct |
428 ms |
24356 KB |
Output is correct |
64 |
Correct |
476 ms |
24356 KB |
Output is correct |
65 |
Correct |
380 ms |
24356 KB |
Output is correct |
66 |
Correct |
289 ms |
24356 KB |
Output is correct |
67 |
Correct |
377 ms |
24356 KB |
Output is correct |
68 |
Correct |
392 ms |
24356 KB |
Output is correct |
69 |
Correct |
365 ms |
24356 KB |
Output is correct |
70 |
Correct |
361 ms |
24356 KB |
Output is correct |
71 |
Correct |
355 ms |
24356 KB |
Output is correct |
72 |
Correct |
367 ms |
24356 KB |
Output is correct |
73 |
Correct |
359 ms |
24356 KB |
Output is correct |
74 |
Correct |
359 ms |
24356 KB |
Output is correct |
75 |
Correct |
361 ms |
24356 KB |
Output is correct |
76 |
Correct |
437 ms |
24356 KB |
Output is correct |
77 |
Correct |
407 ms |
24356 KB |
Output is correct |
78 |
Correct |
351 ms |
24356 KB |
Output is correct |
79 |
Correct |
542 ms |
24356 KB |
Output is correct |
80 |
Correct |
324 ms |
24356 KB |
Output is correct |
81 |
Correct |
1353 ms |
24356 KB |
Output is correct |
82 |
Correct |
1321 ms |
24356 KB |
Output is correct |
83 |
Correct |
1295 ms |
24356 KB |
Output is correct |
84 |
Correct |
1287 ms |
24356 KB |
Output is correct |
85 |
Correct |
1296 ms |
24424 KB |
Output is correct |
86 |
Correct |
1368 ms |
24424 KB |
Output is correct |
87 |
Correct |
1299 ms |
24424 KB |
Output is correct |
88 |
Correct |
1335 ms |
24424 KB |
Output is correct |
89 |
Correct |
1312 ms |
24476 KB |
Output is correct |
90 |
Correct |
1218 ms |
24476 KB |
Output is correct |
91 |
Correct |
1345 ms |
24476 KB |
Output is correct |
92 |
Correct |
1366 ms |
24476 KB |
Output is correct |
93 |
Correct |
1437 ms |
24476 KB |
Output is correct |
94 |
Correct |
1393 ms |
24476 KB |
Output is correct |
95 |
Correct |
1373 ms |
24476 KB |
Output is correct |
96 |
Correct |
1311 ms |
24476 KB |
Output is correct |
97 |
Correct |
1561 ms |
24476 KB |
Output is correct |
98 |
Correct |
1115 ms |
24476 KB |
Output is correct |
99 |
Correct |
1429 ms |
24476 KB |
Output is correct |
100 |
Correct |
1498 ms |
24476 KB |
Output is correct |
101 |
Correct |
1127 ms |
24476 KB |
Output is correct |
102 |
Correct |
1356 ms |
24476 KB |
Output is correct |
103 |
Correct |
1581 ms |
24476 KB |
Output is correct |
104 |
Correct |
1590 ms |
24476 KB |
Output is correct |
105 |
Correct |
961 ms |
24476 KB |
Output is correct |
106 |
Correct |
1207 ms |
24476 KB |
Output is correct |
107 |
Correct |
1187 ms |
24476 KB |
Output is correct |
108 |
Correct |
1267 ms |
24476 KB |
Output is correct |
109 |
Correct |
1213 ms |
24476 KB |
Output is correct |
110 |
Correct |
1208 ms |
24476 KB |
Output is correct |
111 |
Correct |
1188 ms |
24476 KB |
Output is correct |
112 |
Correct |
1284 ms |
24476 KB |
Output is correct |
113 |
Correct |
1219 ms |
24476 KB |
Output is correct |
114 |
Correct |
1295 ms |
24476 KB |
Output is correct |
115 |
Correct |
1217 ms |
24476 KB |
Output is correct |
116 |
Correct |
1129 ms |
24476 KB |
Output is correct |