#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
typedef vector<int> vi;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
int n;
i4 arr[300005];
int X[300005],Y[300005],R[300005];
int proc=0;
int ans[300005];
ll scale=(1LL<<32);
map<ii,vector<int> > m;
inline void downscale(){
m.clear();
for(int x=proc;x<n;x++){
i4 i=arr[x];
if(ans[-i.fi.se]==-1)m[mp(i.se.fi/scale,i.se.se/scale)].pb(-i.fi.se);
}
}
inline bool intersect(int a,int b){
ll dx=X[a]-X[b];
ll dy=Y[a]-Y[b];
ll r=R[a]+R[b];
return (dx*dx<=r*r-dy*dy);
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d%d",&X[i],&Y[i],&R[i]);
X[i]+=MOD;Y[i]+=MOD;
arr[i]=mp(mp(R[i],-i),mp(X[i],Y[i]));
}
memset(ans,-1,sizeof(ans));
sort(arr,arr+n);
reverse(arr,arr+n);
downscale();
for(;proc<n;proc++){
i4 cur=arr[proc];
int index=-cur.fi.se;
if(ans[index]!=-1)continue;
ans[index]=index;
bool change=0;
while(scale>2*cur.fi.fi){scale/=2;change=1;}
if(change)downscale();
int x=cur.se.fi/scale,y=cur.se.se/scale;
for(int i=x-2;i<=x+2;i++){
for(int j=y-2;j<=y+2;j++){
if(m.find(mp(i,j))==m.end())continue;
vector<int> &v1=m[mp(i,j)];
vector<int> v2;
for(int k:v1){
if(ans[k]==-1&&intersect(k,index)){
ans[k]=index;
}else if(ans[k]==-1){
v2.pb(k);
}
}
swap(m[mp(i,j)],v2);
}
}
}
for(int i=0;i<n;i++)printf("%d ",ans[i]+1);
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
circle_selection.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%d%d%d",&X[i],&Y[i],&R[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
1 ms |
1492 KB |
Output is correct |
17 |
Correct |
1 ms |
1472 KB |
Output is correct |
18 |
Correct |
1 ms |
1492 KB |
Output is correct |
19 |
Correct |
3 ms |
1620 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Correct |
3 ms |
1620 KB |
Output is correct |
22 |
Correct |
12 ms |
2180 KB |
Output is correct |
23 |
Correct |
14 ms |
2180 KB |
Output is correct |
24 |
Correct |
12 ms |
2132 KB |
Output is correct |
25 |
Correct |
13 ms |
2132 KB |
Output is correct |
26 |
Correct |
12 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
13780 KB |
Output is correct |
2 |
Correct |
123 ms |
13664 KB |
Output is correct |
3 |
Correct |
123 ms |
14048 KB |
Output is correct |
4 |
Correct |
120 ms |
13880 KB |
Output is correct |
5 |
Correct |
169 ms |
13984 KB |
Output is correct |
6 |
Correct |
544 ms |
24428 KB |
Output is correct |
7 |
Correct |
206 ms |
19584 KB |
Output is correct |
8 |
Correct |
260 ms |
21880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
380 ms |
15648 KB |
Output is correct |
3 |
Correct |
1692 ms |
52660 KB |
Output is correct |
4 |
Correct |
1588 ms |
52580 KB |
Output is correct |
5 |
Correct |
1608 ms |
46964 KB |
Output is correct |
6 |
Correct |
501 ms |
24216 KB |
Output is correct |
7 |
Correct |
208 ms |
13388 KB |
Output is correct |
8 |
Correct |
30 ms |
3940 KB |
Output is correct |
9 |
Correct |
1868 ms |
51452 KB |
Output is correct |
10 |
Correct |
1437 ms |
44176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1315 ms |
44548 KB |
Output is correct |
2 |
Correct |
885 ms |
51648 KB |
Output is correct |
3 |
Correct |
330 ms |
27664 KB |
Output is correct |
4 |
Correct |
946 ms |
51912 KB |
Output is correct |
5 |
Correct |
890 ms |
52100 KB |
Output is correct |
6 |
Correct |
179 ms |
22716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
1 ms |
1492 KB |
Output is correct |
17 |
Correct |
1 ms |
1472 KB |
Output is correct |
18 |
Correct |
1 ms |
1492 KB |
Output is correct |
19 |
Correct |
3 ms |
1620 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Correct |
3 ms |
1620 KB |
Output is correct |
22 |
Correct |
12 ms |
2180 KB |
Output is correct |
23 |
Correct |
14 ms |
2180 KB |
Output is correct |
24 |
Correct |
12 ms |
2132 KB |
Output is correct |
25 |
Correct |
13 ms |
2132 KB |
Output is correct |
26 |
Correct |
12 ms |
2132 KB |
Output is correct |
27 |
Correct |
5 ms |
1876 KB |
Output is correct |
28 |
Correct |
5 ms |
1876 KB |
Output is correct |
29 |
Correct |
5 ms |
1876 KB |
Output is correct |
30 |
Correct |
26 ms |
2864 KB |
Output is correct |
31 |
Correct |
26 ms |
2892 KB |
Output is correct |
32 |
Correct |
24 ms |
2892 KB |
Output is correct |
33 |
Correct |
42 ms |
5112 KB |
Output is correct |
34 |
Correct |
41 ms |
5044 KB |
Output is correct |
35 |
Correct |
43 ms |
5472 KB |
Output is correct |
36 |
Correct |
393 ms |
15748 KB |
Output is correct |
37 |
Correct |
319 ms |
18332 KB |
Output is correct |
38 |
Correct |
367 ms |
18444 KB |
Output is correct |
39 |
Correct |
330 ms |
11984 KB |
Output is correct |
40 |
Correct |
335 ms |
12060 KB |
Output is correct |
41 |
Correct |
318 ms |
12040 KB |
Output is correct |
42 |
Correct |
205 ms |
13012 KB |
Output is correct |
43 |
Correct |
224 ms |
18032 KB |
Output is correct |
44 |
Correct |
238 ms |
18072 KB |
Output is correct |
45 |
Correct |
230 ms |
18028 KB |
Output is correct |
46 |
Correct |
224 ms |
18040 KB |
Output is correct |
47 |
Correct |
275 ms |
18080 KB |
Output is correct |
48 |
Correct |
228 ms |
18068 KB |
Output is correct |
49 |
Correct |
222 ms |
18108 KB |
Output is correct |
50 |
Correct |
233 ms |
18132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
1 ms |
1492 KB |
Output is correct |
17 |
Correct |
1 ms |
1472 KB |
Output is correct |
18 |
Correct |
1 ms |
1492 KB |
Output is correct |
19 |
Correct |
3 ms |
1620 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Correct |
3 ms |
1620 KB |
Output is correct |
22 |
Correct |
12 ms |
2180 KB |
Output is correct |
23 |
Correct |
14 ms |
2180 KB |
Output is correct |
24 |
Correct |
12 ms |
2132 KB |
Output is correct |
25 |
Correct |
13 ms |
2132 KB |
Output is correct |
26 |
Correct |
12 ms |
2132 KB |
Output is correct |
27 |
Correct |
124 ms |
13780 KB |
Output is correct |
28 |
Correct |
123 ms |
13664 KB |
Output is correct |
29 |
Correct |
123 ms |
14048 KB |
Output is correct |
30 |
Correct |
120 ms |
13880 KB |
Output is correct |
31 |
Correct |
169 ms |
13984 KB |
Output is correct |
32 |
Correct |
544 ms |
24428 KB |
Output is correct |
33 |
Correct |
206 ms |
19584 KB |
Output is correct |
34 |
Correct |
260 ms |
21880 KB |
Output is correct |
35 |
Correct |
1 ms |
1492 KB |
Output is correct |
36 |
Correct |
380 ms |
15648 KB |
Output is correct |
37 |
Correct |
1692 ms |
52660 KB |
Output is correct |
38 |
Correct |
1588 ms |
52580 KB |
Output is correct |
39 |
Correct |
1608 ms |
46964 KB |
Output is correct |
40 |
Correct |
501 ms |
24216 KB |
Output is correct |
41 |
Correct |
208 ms |
13388 KB |
Output is correct |
42 |
Correct |
30 ms |
3940 KB |
Output is correct |
43 |
Correct |
1868 ms |
51452 KB |
Output is correct |
44 |
Correct |
1437 ms |
44176 KB |
Output is correct |
45 |
Correct |
1315 ms |
44548 KB |
Output is correct |
46 |
Correct |
885 ms |
51648 KB |
Output is correct |
47 |
Correct |
330 ms |
27664 KB |
Output is correct |
48 |
Correct |
946 ms |
51912 KB |
Output is correct |
49 |
Correct |
890 ms |
52100 KB |
Output is correct |
50 |
Correct |
179 ms |
22716 KB |
Output is correct |
51 |
Correct |
5 ms |
1876 KB |
Output is correct |
52 |
Correct |
5 ms |
1876 KB |
Output is correct |
53 |
Correct |
5 ms |
1876 KB |
Output is correct |
54 |
Correct |
26 ms |
2864 KB |
Output is correct |
55 |
Correct |
26 ms |
2892 KB |
Output is correct |
56 |
Correct |
24 ms |
2892 KB |
Output is correct |
57 |
Correct |
42 ms |
5112 KB |
Output is correct |
58 |
Correct |
41 ms |
5044 KB |
Output is correct |
59 |
Correct |
43 ms |
5472 KB |
Output is correct |
60 |
Correct |
393 ms |
15748 KB |
Output is correct |
61 |
Correct |
319 ms |
18332 KB |
Output is correct |
62 |
Correct |
367 ms |
18444 KB |
Output is correct |
63 |
Correct |
330 ms |
11984 KB |
Output is correct |
64 |
Correct |
335 ms |
12060 KB |
Output is correct |
65 |
Correct |
318 ms |
12040 KB |
Output is correct |
66 |
Correct |
205 ms |
13012 KB |
Output is correct |
67 |
Correct |
224 ms |
18032 KB |
Output is correct |
68 |
Correct |
238 ms |
18072 KB |
Output is correct |
69 |
Correct |
230 ms |
18028 KB |
Output is correct |
70 |
Correct |
224 ms |
18040 KB |
Output is correct |
71 |
Correct |
275 ms |
18080 KB |
Output is correct |
72 |
Correct |
228 ms |
18068 KB |
Output is correct |
73 |
Correct |
222 ms |
18108 KB |
Output is correct |
74 |
Correct |
233 ms |
18132 KB |
Output is correct |
75 |
Correct |
136 ms |
22568 KB |
Output is correct |
76 |
Correct |
131 ms |
22888 KB |
Output is correct |
77 |
Correct |
133 ms |
22532 KB |
Output is correct |
78 |
Correct |
131 ms |
22088 KB |
Output is correct |
79 |
Correct |
152 ms |
22516 KB |
Output is correct |
80 |
Correct |
125 ms |
21812 KB |
Output is correct |
81 |
Correct |
1795 ms |
52516 KB |
Output is correct |
82 |
Correct |
1445 ms |
52356 KB |
Output is correct |
83 |
Correct |
1645 ms |
52288 KB |
Output is correct |
84 |
Correct |
1630 ms |
52772 KB |
Output is correct |
85 |
Correct |
1585 ms |
52376 KB |
Output is correct |
86 |
Correct |
1446 ms |
52464 KB |
Output is correct |
87 |
Correct |
1773 ms |
52204 KB |
Output is correct |
88 |
Correct |
1390 ms |
33584 KB |
Output is correct |
89 |
Correct |
1264 ms |
33468 KB |
Output is correct |
90 |
Correct |
1294 ms |
33476 KB |
Output is correct |
91 |
Correct |
1318 ms |
33400 KB |
Output is correct |
92 |
Correct |
1372 ms |
33456 KB |
Output is correct |
93 |
Correct |
1260 ms |
51364 KB |
Output is correct |
94 |
Correct |
1170 ms |
51528 KB |
Output is correct |
95 |
Correct |
1307 ms |
51364 KB |
Output is correct |
96 |
Correct |
1410 ms |
51228 KB |
Output is correct |
97 |
Correct |
1709 ms |
51308 KB |
Output is correct |
98 |
Correct |
718 ms |
35340 KB |
Output is correct |
99 |
Correct |
1220 ms |
51524 KB |
Output is correct |
100 |
Correct |
1168 ms |
51348 KB |
Output is correct |
101 |
Correct |
1122 ms |
40168 KB |
Output is correct |
102 |
Correct |
1207 ms |
50816 KB |
Output is correct |
103 |
Correct |
1829 ms |
49964 KB |
Output is correct |
104 |
Correct |
1093 ms |
51240 KB |
Output is correct |
105 |
Correct |
924 ms |
36276 KB |
Output is correct |
106 |
Correct |
843 ms |
50008 KB |
Output is correct |
107 |
Correct |
821 ms |
50072 KB |
Output is correct |
108 |
Correct |
838 ms |
49964 KB |
Output is correct |
109 |
Correct |
843 ms |
50052 KB |
Output is correct |
110 |
Correct |
852 ms |
50180 KB |
Output is correct |
111 |
Correct |
864 ms |
50012 KB |
Output is correct |
112 |
Correct |
802 ms |
50032 KB |
Output is correct |
113 |
Correct |
831 ms |
50024 KB |
Output is correct |
114 |
Correct |
901 ms |
50036 KB |
Output is correct |
115 |
Correct |
833 ms |
50052 KB |
Output is correct |
116 |
Correct |
826 ms |
50012 KB |
Output is correct |