#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=5e5;
int N,x_,y_,r_,R_cur,R_next,order[MAX],par[MAX];
struct circle
{
int X;
int Y;
int R;
int ind;
void init(int X_,int Y_,int R_,int ind_)
{
X=X_;
Y=Y_;
R=R_;
ind=ind_;
}
} arr[MAX],lol[MAX];
bool operator<(circle F,circle S)
{
if(F.X==S.X)
return F.Y<S.Y;
return F.X<S.X;
}
bool cmp(int F,int S)
{
if(lol[F].R==lol[S].R)
return lol[F].ind<lol[S].ind;
return lol[F].R>lol[S].R;
}
bool ok(int F,int S)
{
return (lol[F].X-lol[S].X)*(lol[F].X-lol[S].X)+(lol[F].Y-lol[S].Y)*(lol[F].Y-lol[S].Y)<=(lol[F].R+lol[S].R)*(lol[F].R+lol[S].R);
}
void init_()
{
R_cur=R_next;
R_next/=2;
for(int A=1;A<=N;A++)
arr[A].init(lol[A].X/R_cur,lol[A].Y/R_cur,lol[A].R,A);
sort(arr+1,arr+N+1);
return ;
}
void solve(int ind)
{
int tem;
int pos_x=lol[ind].X/R_cur;
int pos_y=lol[ind].Y/R_cur;
par[ind]=ind;
for(int cur_x=pos_x-2;cur_x<=pos_x+2;cur_x++)
{
tem=lower_bound(arr+1,arr+N+1,(circle){cur_x,pos_y-2,0,0})-arr;
while(tem<=N and arr[tem].X==cur_x and arr[tem].Y<=pos_y+2)
{
//cout<<arr[tem].ind<<" "<<ind<<"\n";
if(par[arr[tem].ind])
{
tem++;
continue;
}
else if(ok(ind,arr[tem].ind))
{
//cout<<ind<<" "<<arr[tem].ind<<"fu \n";
par[arr[tem].ind]=ind;
}
tem++;
}
}
return ;
}
signed main()
{
ios_base::sync_with_stdio(false);
/*cin.tie(0);
cout.tie(0);*/
/* input
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
cin>>N;
for(int A=1;A<=N;A++)
{
cin>>x_>>y_>>r_;
order[A]=A;
lol[A].init(x_,y_,r_,A);
R_cur=max(R_cur,lol[A].R);
}
R_next=R_cur;
init_();
sort(order+1,order+N+1,cmp);
for(int A=1;A<=N;A++)
{
if(par[order[A]])
continue;
solve(order[A]);
}
for(int A=1;A<=N;A++)
cout<<par[A]<<" ";
return 0;
}
# |
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 |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
760 KB |
Output is correct |
12 |
Correct |
2 ms |
760 KB |
Output is correct |
13 |
Correct |
2 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
2 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
6 ms |
996 KB |
Output is correct |
20 |
Correct |
5 ms |
1000 KB |
Output is correct |
21 |
Correct |
6 ms |
1140 KB |
Output is correct |
22 |
Correct |
9 ms |
1140 KB |
Output is correct |
23 |
Correct |
9 ms |
1140 KB |
Output is correct |
24 |
Correct |
10 ms |
1140 KB |
Output is correct |
25 |
Correct |
8 ms |
1140 KB |
Output is correct |
26 |
Correct |
8 ms |
1140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
246 ms |
26152 KB |
Output is correct |
2 |
Correct |
253 ms |
26288 KB |
Output is correct |
3 |
Correct |
276 ms |
26288 KB |
Output is correct |
4 |
Correct |
290 ms |
26288 KB |
Output is correct |
5 |
Correct |
323 ms |
26288 KB |
Output is correct |
6 |
Correct |
384 ms |
26288 KB |
Output is correct |
7 |
Correct |
282 ms |
26288 KB |
Output is correct |
8 |
Correct |
315 ms |
26288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
26288 KB |
Output is correct |
2 |
Correct |
192 ms |
26288 KB |
Output is correct |
3 |
Correct |
691 ms |
26288 KB |
Output is correct |
4 |
Correct |
816 ms |
26288 KB |
Output is correct |
5 |
Correct |
870 ms |
26288 KB |
Output is correct |
6 |
Correct |
313 ms |
26288 KB |
Output is correct |
7 |
Correct |
155 ms |
26288 KB |
Output is correct |
8 |
Correct |
21 ms |
26288 KB |
Output is correct |
9 |
Correct |
732 ms |
26288 KB |
Output is correct |
10 |
Correct |
622 ms |
26288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
609 ms |
26288 KB |
Output is correct |
2 |
Correct |
501 ms |
26288 KB |
Output is correct |
3 |
Correct |
303 ms |
26288 KB |
Output is correct |
4 |
Correct |
527 ms |
26288 KB |
Output is correct |
5 |
Correct |
499 ms |
26288 KB |
Output is correct |
6 |
Correct |
271 ms |
26288 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 |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
760 KB |
Output is correct |
12 |
Correct |
2 ms |
760 KB |
Output is correct |
13 |
Correct |
2 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
2 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
6 ms |
996 KB |
Output is correct |
20 |
Correct |
5 ms |
1000 KB |
Output is correct |
21 |
Correct |
6 ms |
1140 KB |
Output is correct |
22 |
Correct |
9 ms |
1140 KB |
Output is correct |
23 |
Correct |
9 ms |
1140 KB |
Output is correct |
24 |
Correct |
10 ms |
1140 KB |
Output is correct |
25 |
Correct |
8 ms |
1140 KB |
Output is correct |
26 |
Correct |
8 ms |
1140 KB |
Output is correct |
27 |
Correct |
11 ms |
26288 KB |
Output is correct |
28 |
Correct |
9 ms |
26288 KB |
Output is correct |
29 |
Correct |
9 ms |
26288 KB |
Output is correct |
30 |
Correct |
17 ms |
26288 KB |
Output is correct |
31 |
Correct |
16 ms |
26288 KB |
Output is correct |
32 |
Correct |
16 ms |
26288 KB |
Output is correct |
33 |
Correct |
84 ms |
26288 KB |
Output is correct |
34 |
Correct |
86 ms |
26288 KB |
Output is correct |
35 |
Correct |
111 ms |
26288 KB |
Output is correct |
36 |
Correct |
179 ms |
26288 KB |
Output is correct |
37 |
Correct |
192 ms |
26288 KB |
Output is correct |
38 |
Correct |
188 ms |
26288 KB |
Output is correct |
39 |
Execution timed out |
3050 ms |
26288 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
760 KB |
Output is correct |
12 |
Correct |
2 ms |
760 KB |
Output is correct |
13 |
Correct |
2 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
2 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
6 ms |
996 KB |
Output is correct |
20 |
Correct |
5 ms |
1000 KB |
Output is correct |
21 |
Correct |
6 ms |
1140 KB |
Output is correct |
22 |
Correct |
9 ms |
1140 KB |
Output is correct |
23 |
Correct |
9 ms |
1140 KB |
Output is correct |
24 |
Correct |
10 ms |
1140 KB |
Output is correct |
25 |
Correct |
8 ms |
1140 KB |
Output is correct |
26 |
Correct |
8 ms |
1140 KB |
Output is correct |
27 |
Correct |
246 ms |
26152 KB |
Output is correct |
28 |
Correct |
253 ms |
26288 KB |
Output is correct |
29 |
Correct |
276 ms |
26288 KB |
Output is correct |
30 |
Correct |
290 ms |
26288 KB |
Output is correct |
31 |
Correct |
323 ms |
26288 KB |
Output is correct |
32 |
Correct |
384 ms |
26288 KB |
Output is correct |
33 |
Correct |
282 ms |
26288 KB |
Output is correct |
34 |
Correct |
315 ms |
26288 KB |
Output is correct |
35 |
Correct |
2 ms |
26288 KB |
Output is correct |
36 |
Correct |
192 ms |
26288 KB |
Output is correct |
37 |
Correct |
691 ms |
26288 KB |
Output is correct |
38 |
Correct |
816 ms |
26288 KB |
Output is correct |
39 |
Correct |
870 ms |
26288 KB |
Output is correct |
40 |
Correct |
313 ms |
26288 KB |
Output is correct |
41 |
Correct |
155 ms |
26288 KB |
Output is correct |
42 |
Correct |
21 ms |
26288 KB |
Output is correct |
43 |
Correct |
732 ms |
26288 KB |
Output is correct |
44 |
Correct |
622 ms |
26288 KB |
Output is correct |
45 |
Correct |
609 ms |
26288 KB |
Output is correct |
46 |
Correct |
501 ms |
26288 KB |
Output is correct |
47 |
Correct |
303 ms |
26288 KB |
Output is correct |
48 |
Correct |
527 ms |
26288 KB |
Output is correct |
49 |
Correct |
499 ms |
26288 KB |
Output is correct |
50 |
Correct |
271 ms |
26288 KB |
Output is correct |
51 |
Correct |
11 ms |
26288 KB |
Output is correct |
52 |
Correct |
9 ms |
26288 KB |
Output is correct |
53 |
Correct |
9 ms |
26288 KB |
Output is correct |
54 |
Correct |
17 ms |
26288 KB |
Output is correct |
55 |
Correct |
16 ms |
26288 KB |
Output is correct |
56 |
Correct |
16 ms |
26288 KB |
Output is correct |
57 |
Correct |
84 ms |
26288 KB |
Output is correct |
58 |
Correct |
86 ms |
26288 KB |
Output is correct |
59 |
Correct |
111 ms |
26288 KB |
Output is correct |
60 |
Correct |
179 ms |
26288 KB |
Output is correct |
61 |
Correct |
192 ms |
26288 KB |
Output is correct |
62 |
Correct |
188 ms |
26288 KB |
Output is correct |
63 |
Execution timed out |
3050 ms |
26288 KB |
Time limit exceeded |
64 |
Halted |
0 ms |
0 KB |
- |