#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define mt make_tuple
struct circle{ ll x,y,r;int id;circle(){}circle(ll a, ll b, ll c):x(a),y(b),r(c){}};
ll sq(ll x){ return x*x;}
bool sec(circle a, circle b){ return sq(a.x-b.x)+sq(a.y-b.y)<=sq(a.r+b.r);}
bool operator < (circle a, circle b){ return a.r<b.r;}
const int N=300050;
const int mul=2e9+7;
circle a[N],b[N];
int ans[N];
vector<tuple<int,int,int>> all;
int main()
{
int n,i;
scanf("%i",&n);
for(i=1;i<=n;i++) scanf("%lld %lld %lld",&a[i].x,&a[i].y,&a[i].r),a[i].id=i,b[i]=a[i];
sort(a+1,a+1+n,[](circle a, circle b){ return a.r>b.r || a.r==b.r && a.id<b.id;});
for(int j=30;j>=0;j--)
{
int po=1<<j;
all.clear();
for(i=1;i<=n;i++) if(!ans[a[i].id])
{
pair<int,int> pa=mp(floor((double)a[i].x/po),floor((double)a[i].y/po));
all.pb(mt(pa.first,pa.second,a[i].id));
}
sort(all.begin(),all.end());
for(i=1;i<=n;i++) if(!ans[a[i].id] && a[i].r>=(1<<j-1))
{
int x=floor((double)a[i].x/po);
int y=floor((double)a[i].y/po);
for(int l=-2;l<=2;l++)
{
ll p=x+l;
int lb=upper_bound(all.begin(),all.end(),mt(x+l,y-3,mul))-all.begin();
//int rb=upper_bound(all[idx].begin(),all[idx].end(),mp(y+2,mul))-all[idx].begin();
for(int r=lb;r<all.size() && all[r]<=mt(x+l,y+2,mul);r++)
{
int c=get<2>(all[r]);
if(!ans[c] && sec(b[c],a[i])) ans[c]=a[i].id;
}
}
}
}
for(i=1;i<=n;i++) printf("%i%c",ans[i],i==n?'\n':' ');
return 0;
}
Compilation message
circle_selection.cpp: In lambda function:
circle_selection.cpp:21:71: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
sort(a+1,a+1+n,[](circle a, circle b){ return a.r>b.r || a.r==b.r && a.id<b.id;});
~~~~~~~~~^~~~~~~~~~~~
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:32:57: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
for(i=1;i<=n;i++) if(!ans[a[i].id] && a[i].r>=(1<<j-1))
~^~
circle_selection.cpp:41:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int r=lb;r<all.size() && all[r]<=mt(x+l,y+2,mul);r++)
~^~~~~~~~~~~
circle_selection.cpp:38:11: warning: unused variable 'p' [-Wunused-variable]
ll p=x+l;
^
circle_selection.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&n);
~~~~~^~~~~~~~~
circle_selection.cpp:20:80: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(i=1;i<=n;i++) scanf("%lld %lld %lld",&a[i].x,&a[i].y,&a[i].r),a[i].id=i,b[i]=a[i];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
8 ms |
896 KB |
Output is correct |
20 |
Correct |
7 ms |
896 KB |
Output is correct |
21 |
Correct |
10 ms |
896 KB |
Output is correct |
22 |
Correct |
18 ms |
900 KB |
Output is correct |
23 |
Correct |
17 ms |
896 KB |
Output is correct |
24 |
Correct |
20 ms |
896 KB |
Output is correct |
25 |
Correct |
22 ms |
888 KB |
Output is correct |
26 |
Correct |
16 ms |
868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
463 ms |
26064 KB |
Output is correct |
2 |
Correct |
496 ms |
26056 KB |
Output is correct |
3 |
Correct |
478 ms |
25880 KB |
Output is correct |
4 |
Correct |
390 ms |
26072 KB |
Output is correct |
5 |
Correct |
1032 ms |
25972 KB |
Output is correct |
6 |
Correct |
1180 ms |
25900 KB |
Output is correct |
7 |
Correct |
1042 ms |
26120 KB |
Output is correct |
8 |
Correct |
1168 ms |
26016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
336 ms |
9076 KB |
Output is correct |
3 |
Correct |
1199 ms |
26072 KB |
Output is correct |
4 |
Correct |
1193 ms |
26032 KB |
Output is correct |
5 |
Correct |
1053 ms |
25288 KB |
Output is correct |
6 |
Correct |
524 ms |
13720 KB |
Output is correct |
7 |
Correct |
253 ms |
7468 KB |
Output is correct |
8 |
Correct |
48 ms |
1908 KB |
Output is correct |
9 |
Correct |
1268 ms |
26088 KB |
Output is correct |
10 |
Correct |
1041 ms |
25944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1124 ms |
25916 KB |
Output is correct |
2 |
Correct |
1512 ms |
25924 KB |
Output is correct |
3 |
Correct |
740 ms |
34056 KB |
Output is correct |
4 |
Correct |
1302 ms |
33612 KB |
Output is correct |
5 |
Correct |
1249 ms |
33656 KB |
Output is correct |
6 |
Correct |
682 ms |
34024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
8 ms |
896 KB |
Output is correct |
20 |
Correct |
7 ms |
896 KB |
Output is correct |
21 |
Correct |
10 ms |
896 KB |
Output is correct |
22 |
Correct |
18 ms |
900 KB |
Output is correct |
23 |
Correct |
17 ms |
896 KB |
Output is correct |
24 |
Correct |
20 ms |
896 KB |
Output is correct |
25 |
Correct |
22 ms |
888 KB |
Output is correct |
26 |
Correct |
16 ms |
868 KB |
Output is correct |
27 |
Correct |
11 ms |
1344 KB |
Output is correct |
28 |
Correct |
12 ms |
1344 KB |
Output is correct |
29 |
Correct |
13 ms |
1280 KB |
Output is correct |
30 |
Correct |
33 ms |
1336 KB |
Output is correct |
31 |
Correct |
35 ms |
1292 KB |
Output is correct |
32 |
Correct |
37 ms |
1300 KB |
Output is correct |
33 |
Correct |
112 ms |
8940 KB |
Output is correct |
34 |
Correct |
100 ms |
8936 KB |
Output is correct |
35 |
Correct |
129 ms |
8992 KB |
Output is correct |
36 |
Correct |
354 ms |
8872 KB |
Output is correct |
37 |
Correct |
380 ms |
8944 KB |
Output is correct |
38 |
Correct |
356 ms |
8932 KB |
Output is correct |
39 |
Correct |
481 ms |
8864 KB |
Output is correct |
40 |
Correct |
486 ms |
8936 KB |
Output is correct |
41 |
Correct |
499 ms |
8940 KB |
Output is correct |
42 |
Correct |
316 ms |
8808 KB |
Output is correct |
43 |
Correct |
349 ms |
8940 KB |
Output is correct |
44 |
Correct |
355 ms |
8940 KB |
Output is correct |
45 |
Correct |
360 ms |
8944 KB |
Output is correct |
46 |
Correct |
349 ms |
8940 KB |
Output is correct |
47 |
Correct |
336 ms |
8852 KB |
Output is correct |
48 |
Correct |
356 ms |
8940 KB |
Output is correct |
49 |
Correct |
357 ms |
8864 KB |
Output is correct |
50 |
Correct |
348 ms |
8936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
8 ms |
896 KB |
Output is correct |
20 |
Correct |
7 ms |
896 KB |
Output is correct |
21 |
Correct |
10 ms |
896 KB |
Output is correct |
22 |
Correct |
18 ms |
900 KB |
Output is correct |
23 |
Correct |
17 ms |
896 KB |
Output is correct |
24 |
Correct |
20 ms |
896 KB |
Output is correct |
25 |
Correct |
22 ms |
888 KB |
Output is correct |
26 |
Correct |
16 ms |
868 KB |
Output is correct |
27 |
Correct |
463 ms |
26064 KB |
Output is correct |
28 |
Correct |
496 ms |
26056 KB |
Output is correct |
29 |
Correct |
478 ms |
25880 KB |
Output is correct |
30 |
Correct |
390 ms |
26072 KB |
Output is correct |
31 |
Correct |
1032 ms |
25972 KB |
Output is correct |
32 |
Correct |
1180 ms |
25900 KB |
Output is correct |
33 |
Correct |
1042 ms |
26120 KB |
Output is correct |
34 |
Correct |
1168 ms |
26016 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
336 ms |
9076 KB |
Output is correct |
37 |
Correct |
1199 ms |
26072 KB |
Output is correct |
38 |
Correct |
1193 ms |
26032 KB |
Output is correct |
39 |
Correct |
1053 ms |
25288 KB |
Output is correct |
40 |
Correct |
524 ms |
13720 KB |
Output is correct |
41 |
Correct |
253 ms |
7468 KB |
Output is correct |
42 |
Correct |
48 ms |
1908 KB |
Output is correct |
43 |
Correct |
1268 ms |
26088 KB |
Output is correct |
44 |
Correct |
1041 ms |
25944 KB |
Output is correct |
45 |
Correct |
1124 ms |
25916 KB |
Output is correct |
46 |
Correct |
1512 ms |
25924 KB |
Output is correct |
47 |
Correct |
740 ms |
34056 KB |
Output is correct |
48 |
Correct |
1302 ms |
33612 KB |
Output is correct |
49 |
Correct |
1249 ms |
33656 KB |
Output is correct |
50 |
Correct |
682 ms |
34024 KB |
Output is correct |
51 |
Correct |
11 ms |
1344 KB |
Output is correct |
52 |
Correct |
12 ms |
1344 KB |
Output is correct |
53 |
Correct |
13 ms |
1280 KB |
Output is correct |
54 |
Correct |
33 ms |
1336 KB |
Output is correct |
55 |
Correct |
35 ms |
1292 KB |
Output is correct |
56 |
Correct |
37 ms |
1300 KB |
Output is correct |
57 |
Correct |
112 ms |
8940 KB |
Output is correct |
58 |
Correct |
100 ms |
8936 KB |
Output is correct |
59 |
Correct |
129 ms |
8992 KB |
Output is correct |
60 |
Correct |
354 ms |
8872 KB |
Output is correct |
61 |
Correct |
380 ms |
8944 KB |
Output is correct |
62 |
Correct |
356 ms |
8932 KB |
Output is correct |
63 |
Correct |
481 ms |
8864 KB |
Output is correct |
64 |
Correct |
486 ms |
8936 KB |
Output is correct |
65 |
Correct |
499 ms |
8940 KB |
Output is correct |
66 |
Correct |
316 ms |
8808 KB |
Output is correct |
67 |
Correct |
349 ms |
8940 KB |
Output is correct |
68 |
Correct |
355 ms |
8940 KB |
Output is correct |
69 |
Correct |
360 ms |
8944 KB |
Output is correct |
70 |
Correct |
349 ms |
8940 KB |
Output is correct |
71 |
Correct |
336 ms |
8852 KB |
Output is correct |
72 |
Correct |
356 ms |
8940 KB |
Output is correct |
73 |
Correct |
357 ms |
8864 KB |
Output is correct |
74 |
Correct |
348 ms |
8936 KB |
Output is correct |
75 |
Correct |
482 ms |
35148 KB |
Output is correct |
76 |
Correct |
505 ms |
34904 KB |
Output is correct |
77 |
Correct |
478 ms |
35132 KB |
Output is correct |
78 |
Correct |
362 ms |
34788 KB |
Output is correct |
79 |
Correct |
529 ms |
34748 KB |
Output is correct |
80 |
Correct |
357 ms |
34812 KB |
Output is correct |
81 |
Correct |
1153 ms |
33996 KB |
Output is correct |
82 |
Correct |
1259 ms |
33852 KB |
Output is correct |
83 |
Correct |
1202 ms |
33860 KB |
Output is correct |
84 |
Correct |
1324 ms |
34372 KB |
Output is correct |
85 |
Correct |
1321 ms |
33944 KB |
Output is correct |
86 |
Correct |
1230 ms |
34136 KB |
Output is correct |
87 |
Correct |
1244 ms |
34000 KB |
Output is correct |
88 |
Correct |
1614 ms |
29148 KB |
Output is correct |
89 |
Correct |
1787 ms |
29400 KB |
Output is correct |
90 |
Correct |
1733 ms |
29304 KB |
Output is correct |
91 |
Correct |
1792 ms |
29180 KB |
Output is correct |
92 |
Correct |
1787 ms |
29144 KB |
Output is correct |
93 |
Correct |
1267 ms |
32856 KB |
Output is correct |
94 |
Correct |
1475 ms |
33368 KB |
Output is correct |
95 |
Correct |
1361 ms |
32940 KB |
Output is correct |
96 |
Correct |
1345 ms |
33120 KB |
Output is correct |
97 |
Correct |
1647 ms |
32984 KB |
Output is correct |
98 |
Correct |
1290 ms |
33240 KB |
Output is correct |
99 |
Correct |
1320 ms |
33232 KB |
Output is correct |
100 |
Correct |
1363 ms |
32700 KB |
Output is correct |
101 |
Correct |
1322 ms |
33244 KB |
Output is correct |
102 |
Correct |
1407 ms |
32988 KB |
Output is correct |
103 |
Correct |
1368 ms |
32924 KB |
Output is correct |
104 |
Correct |
1354 ms |
32836 KB |
Output is correct |
105 |
Correct |
1064 ms |
30780 KB |
Output is correct |
106 |
Correct |
1222 ms |
33680 KB |
Output is correct |
107 |
Correct |
1175 ms |
33860 KB |
Output is correct |
108 |
Correct |
1253 ms |
33804 KB |
Output is correct |
109 |
Correct |
1264 ms |
33752 KB |
Output is correct |
110 |
Correct |
1252 ms |
33752 KB |
Output is correct |
111 |
Correct |
1226 ms |
33880 KB |
Output is correct |
112 |
Correct |
1186 ms |
33796 KB |
Output is correct |
113 |
Correct |
1128 ms |
33752 KB |
Output is correct |
114 |
Correct |
1137 ms |
33752 KB |
Output is correct |
115 |
Correct |
1109 ms |
33624 KB |
Output is correct |
116 |
Correct |
1084 ms |
33660 KB |
Output is correct |