#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
using pii=pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
struct circle{
int x, y, r, ind;
circle(int X=0, int Y=0, int R=0) : x(X), y(Y), r(R){}
};
bool operator< (circle a, circle b){
return a.r!=b.r? a.r>b.r : a.ind<b.ind;
}
const int MAXN=300010, LOG=32, dif[3]={-1, 0, 1};
int n, ans[MAXN];
circle arr[MAXN];
map<pii, vector<circle>> cir[LOG];
bool inters(circle a, circle b){
long long dx=a.x-b.x, dy=a.y-b.y, sr=a.r+b.r;
return dx*dx <= sr*sr - dy*dy;
}
void insert(circle c){
int k=8*sizeof(int)-__builtin_clz(c.r);
cir[k][{c.x>>(k+1), c.y>>(k+1)}].push_back(c);
}
int check(circle c){
circle ret; ret.ind=-1;
forn(k, LOG){
int nx=c.x>>(k+1), ny=c.y>>(k+1);
forn(i, 3) forn(j, 3){
auto itr=cir[k].find({nx+dif[i], ny+dif[j]});
if(itr!=cir[k].end()) for(auto cr:(itr->second)) if(inters(c, cr)) ret=min(ret, cr);
}
}
return ret.ind;
}
int main(){
scanf("%d", &n);
forn(i, n) scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r), arr[i].ind=i;
sort(arr, arr+n);
forn(i, n){
int val = check(arr[i]);
if(val==-1){
ans[arr[i].ind]=arr[i].ind;
insert(arr[i]);
}
else ans[arr[i].ind]=val;
}
forn(i, n) printf("%d ", ans[i]+1);
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
circle_selection.cpp:48:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | forn(i, n) scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r), arr[i].ind=i;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
4948 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
2 ms |
4948 KB |
Output is correct |
9 |
Correct |
2 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
4 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
8 ms |
5008 KB |
Output is correct |
20 |
Correct |
6 ms |
4948 KB |
Output is correct |
21 |
Correct |
7 ms |
4948 KB |
Output is correct |
22 |
Correct |
15 ms |
5488 KB |
Output is correct |
23 |
Correct |
17 ms |
5476 KB |
Output is correct |
24 |
Correct |
13 ms |
5588 KB |
Output is correct |
25 |
Correct |
11 ms |
5588 KB |
Output is correct |
26 |
Correct |
14 ms |
5512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
283 ms |
8176 KB |
Output is correct |
2 |
Correct |
267 ms |
8176 KB |
Output is correct |
3 |
Correct |
267 ms |
7924 KB |
Output is correct |
4 |
Correct |
268 ms |
8196 KB |
Output is correct |
5 |
Correct |
558 ms |
8444 KB |
Output is correct |
6 |
Correct |
904 ms |
18420 KB |
Output is correct |
7 |
Correct |
673 ms |
13972 KB |
Output is correct |
8 |
Correct |
654 ms |
15516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
437 ms |
16948 KB |
Output is correct |
3 |
Correct |
1445 ms |
49048 KB |
Output is correct |
4 |
Correct |
1455 ms |
49004 KB |
Output is correct |
5 |
Correct |
1481 ms |
39336 KB |
Output is correct |
6 |
Correct |
579 ms |
19400 KB |
Output is correct |
7 |
Correct |
262 ms |
12492 KB |
Output is correct |
8 |
Correct |
40 ms |
6540 KB |
Output is correct |
9 |
Correct |
1885 ms |
47376 KB |
Output is correct |
10 |
Correct |
1469 ms |
32860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
876 ms |
40964 KB |
Output is correct |
2 |
Correct |
657 ms |
48064 KB |
Output is correct |
3 |
Correct |
599 ms |
17496 KB |
Output is correct |
4 |
Correct |
700 ms |
48416 KB |
Output is correct |
5 |
Correct |
668 ms |
48620 KB |
Output is correct |
6 |
Correct |
476 ms |
16248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
4948 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
2 ms |
4948 KB |
Output is correct |
9 |
Correct |
2 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
4 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
8 ms |
5008 KB |
Output is correct |
20 |
Correct |
6 ms |
4948 KB |
Output is correct |
21 |
Correct |
7 ms |
4948 KB |
Output is correct |
22 |
Correct |
15 ms |
5488 KB |
Output is correct |
23 |
Correct |
17 ms |
5476 KB |
Output is correct |
24 |
Correct |
13 ms |
5588 KB |
Output is correct |
25 |
Correct |
11 ms |
5588 KB |
Output is correct |
26 |
Correct |
14 ms |
5512 KB |
Output is correct |
27 |
Correct |
11 ms |
5076 KB |
Output is correct |
28 |
Correct |
11 ms |
5044 KB |
Output is correct |
29 |
Correct |
13 ms |
4996 KB |
Output is correct |
30 |
Correct |
30 ms |
6100 KB |
Output is correct |
31 |
Correct |
29 ms |
6136 KB |
Output is correct |
32 |
Correct |
24 ms |
6100 KB |
Output is correct |
33 |
Correct |
93 ms |
5884 KB |
Output is correct |
34 |
Correct |
90 ms |
5884 KB |
Output is correct |
35 |
Correct |
98 ms |
5964 KB |
Output is correct |
36 |
Correct |
370 ms |
16952 KB |
Output is correct |
37 |
Correct |
385 ms |
19564 KB |
Output is correct |
38 |
Correct |
374 ms |
19532 KB |
Output is correct |
39 |
Correct |
365 ms |
9380 KB |
Output is correct |
40 |
Correct |
340 ms |
9464 KB |
Output is correct |
41 |
Correct |
342 ms |
9388 KB |
Output is correct |
42 |
Correct |
189 ms |
9100 KB |
Output is correct |
43 |
Correct |
191 ms |
18468 KB |
Output is correct |
44 |
Correct |
207 ms |
18476 KB |
Output is correct |
45 |
Correct |
205 ms |
18408 KB |
Output is correct |
46 |
Correct |
185 ms |
18408 KB |
Output is correct |
47 |
Correct |
183 ms |
18408 KB |
Output is correct |
48 |
Correct |
207 ms |
18508 KB |
Output is correct |
49 |
Correct |
213 ms |
18552 KB |
Output is correct |
50 |
Correct |
184 ms |
18416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
3 ms |
4948 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
2 ms |
4948 KB |
Output is correct |
9 |
Correct |
2 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
4 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
8 ms |
5008 KB |
Output is correct |
20 |
Correct |
6 ms |
4948 KB |
Output is correct |
21 |
Correct |
7 ms |
4948 KB |
Output is correct |
22 |
Correct |
15 ms |
5488 KB |
Output is correct |
23 |
Correct |
17 ms |
5476 KB |
Output is correct |
24 |
Correct |
13 ms |
5588 KB |
Output is correct |
25 |
Correct |
11 ms |
5588 KB |
Output is correct |
26 |
Correct |
14 ms |
5512 KB |
Output is correct |
27 |
Correct |
283 ms |
8176 KB |
Output is correct |
28 |
Correct |
267 ms |
8176 KB |
Output is correct |
29 |
Correct |
267 ms |
7924 KB |
Output is correct |
30 |
Correct |
268 ms |
8196 KB |
Output is correct |
31 |
Correct |
558 ms |
8444 KB |
Output is correct |
32 |
Correct |
904 ms |
18420 KB |
Output is correct |
33 |
Correct |
673 ms |
13972 KB |
Output is correct |
34 |
Correct |
654 ms |
15516 KB |
Output is correct |
35 |
Correct |
3 ms |
4948 KB |
Output is correct |
36 |
Correct |
437 ms |
16948 KB |
Output is correct |
37 |
Correct |
1445 ms |
49048 KB |
Output is correct |
38 |
Correct |
1455 ms |
49004 KB |
Output is correct |
39 |
Correct |
1481 ms |
39336 KB |
Output is correct |
40 |
Correct |
579 ms |
19400 KB |
Output is correct |
41 |
Correct |
262 ms |
12492 KB |
Output is correct |
42 |
Correct |
40 ms |
6540 KB |
Output is correct |
43 |
Correct |
1885 ms |
47376 KB |
Output is correct |
44 |
Correct |
1469 ms |
32860 KB |
Output is correct |
45 |
Correct |
876 ms |
40964 KB |
Output is correct |
46 |
Correct |
657 ms |
48064 KB |
Output is correct |
47 |
Correct |
599 ms |
17496 KB |
Output is correct |
48 |
Correct |
700 ms |
48416 KB |
Output is correct |
49 |
Correct |
668 ms |
48620 KB |
Output is correct |
50 |
Correct |
476 ms |
16248 KB |
Output is correct |
51 |
Correct |
11 ms |
5076 KB |
Output is correct |
52 |
Correct |
11 ms |
5044 KB |
Output is correct |
53 |
Correct |
13 ms |
4996 KB |
Output is correct |
54 |
Correct |
30 ms |
6100 KB |
Output is correct |
55 |
Correct |
29 ms |
6136 KB |
Output is correct |
56 |
Correct |
24 ms |
6100 KB |
Output is correct |
57 |
Correct |
93 ms |
5884 KB |
Output is correct |
58 |
Correct |
90 ms |
5884 KB |
Output is correct |
59 |
Correct |
98 ms |
5964 KB |
Output is correct |
60 |
Correct |
370 ms |
16952 KB |
Output is correct |
61 |
Correct |
385 ms |
19564 KB |
Output is correct |
62 |
Correct |
374 ms |
19532 KB |
Output is correct |
63 |
Correct |
365 ms |
9380 KB |
Output is correct |
64 |
Correct |
340 ms |
9464 KB |
Output is correct |
65 |
Correct |
342 ms |
9388 KB |
Output is correct |
66 |
Correct |
189 ms |
9100 KB |
Output is correct |
67 |
Correct |
191 ms |
18468 KB |
Output is correct |
68 |
Correct |
207 ms |
18476 KB |
Output is correct |
69 |
Correct |
205 ms |
18408 KB |
Output is correct |
70 |
Correct |
185 ms |
18408 KB |
Output is correct |
71 |
Correct |
183 ms |
18408 KB |
Output is correct |
72 |
Correct |
207 ms |
18508 KB |
Output is correct |
73 |
Correct |
213 ms |
18552 KB |
Output is correct |
74 |
Correct |
184 ms |
18416 KB |
Output is correct |
75 |
Correct |
321 ms |
17264 KB |
Output is correct |
76 |
Correct |
294 ms |
17008 KB |
Output is correct |
77 |
Correct |
280 ms |
17212 KB |
Output is correct |
78 |
Correct |
288 ms |
16876 KB |
Output is correct |
79 |
Correct |
407 ms |
17080 KB |
Output is correct |
80 |
Correct |
322 ms |
16924 KB |
Output is correct |
81 |
Correct |
1753 ms |
48952 KB |
Output is correct |
82 |
Correct |
1286 ms |
48868 KB |
Output is correct |
83 |
Correct |
1652 ms |
48784 KB |
Output is correct |
84 |
Correct |
1691 ms |
49220 KB |
Output is correct |
85 |
Correct |
1524 ms |
48864 KB |
Output is correct |
86 |
Correct |
1539 ms |
48880 KB |
Output is correct |
87 |
Correct |
1666 ms |
48364 KB |
Output is correct |
88 |
Correct |
1118 ms |
18412 KB |
Output is correct |
89 |
Correct |
1201 ms |
18412 KB |
Output is correct |
90 |
Correct |
1123 ms |
18488 KB |
Output is correct |
91 |
Correct |
1148 ms |
18496 KB |
Output is correct |
92 |
Correct |
1173 ms |
18392 KB |
Output is correct |
93 |
Correct |
1018 ms |
47800 KB |
Output is correct |
94 |
Correct |
926 ms |
47752 KB |
Output is correct |
95 |
Correct |
1002 ms |
47952 KB |
Output is correct |
96 |
Correct |
1082 ms |
47788 KB |
Output is correct |
97 |
Correct |
1482 ms |
47788 KB |
Output is correct |
98 |
Correct |
954 ms |
27232 KB |
Output is correct |
99 |
Correct |
1035 ms |
47904 KB |
Output is correct |
100 |
Correct |
961 ms |
48144 KB |
Output is correct |
101 |
Correct |
1002 ms |
31752 KB |
Output is correct |
102 |
Correct |
956 ms |
46336 KB |
Output is correct |
103 |
Correct |
1623 ms |
46472 KB |
Output is correct |
104 |
Correct |
924 ms |
47752 KB |
Output is correct |
105 |
Correct |
699 ms |
17560 KB |
Output is correct |
106 |
Correct |
708 ms |
40928 KB |
Output is correct |
107 |
Correct |
705 ms |
40864 KB |
Output is correct |
108 |
Correct |
712 ms |
40884 KB |
Output is correct |
109 |
Correct |
709 ms |
40800 KB |
Output is correct |
110 |
Correct |
751 ms |
40836 KB |
Output is correct |
111 |
Correct |
678 ms |
40936 KB |
Output is correct |
112 |
Correct |
686 ms |
40952 KB |
Output is correct |
113 |
Correct |
708 ms |
40872 KB |
Output is correct |
114 |
Correct |
670 ms |
40996 KB |
Output is correct |
115 |
Correct |
653 ms |
40856 KB |
Output is correct |
116 |
Correct |
644 ms |
40780 KB |
Output is correct |