#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pp;
const int MAXN=300000;
const int rnd=1956748957;
bool vis[MAXN];
int n,cr,outp[MAXN],inp[MAXN][3];
pp take[MAXN];
gp_hash_table<int,vector<int>>plane;
int cmp(int a,int b){
return a*rnd+b;
}
int h;
void initialize(int cx,int cy){
h=cmp(cx,cy);
if(plane.find(h)==plane.end()){
vector<int>temp;
plane[h]=temp;
}
}
void create(){
plane.clear();
for(pp i:take){
if(vis[i.second])continue;
int cx=(inp[i.second][0]>>cr);
int cy=(inp[i.second][1]>>cr);
initialize(cx,cy);
plane[cmp(cx,cy)].push_back(i.second);
}
}
ll xx,yy,rr;
bool intersect(int a,int b){
xx=inp[a][0]-inp[b][0];
yy=inp[a][1]-inp[b][1];
rr=inp[a][2]+inp[b][2];
if(xx*xx+yy*yy<=rr*rr)return true;
return false;
}
void calc(int c){
int cx=(inp[c][0]>>cr);
int cy=(inp[c][1]>>cr);
for(int i=-1;i<=1;i++){
for(int y=-1;y<=1;y++){
if(plane.find(cmp(cx+i,cy+y))==plane.end())continue;
for(int i:plane[cmp(cx+i,cy+y)]){
if(!vis[i]&&intersect(i,c)){
outp[i]=c;
vis[i]=true;
}
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(vis,false,sizeof(vis));
cin>>n;
for(int i=0;i<n;i++){
cin>>inp[i][0]>>inp[i][1]>>inp[i][2];
take[i]={-inp[i][2],i};
}
sort(take,take+n);
cr=30;
create();
bool change=false;
for(int i=0;i<n;i++){
if(vis[take[i].second])continue;
while(-take[i].first<(double)(1<<(cr-2))/sqrt(2)){
cr--;
change=true;
}
if(change)create();
change=false;
calc(take[i].second);
}
for(int i=0;i<n-1;i++)cout<<outp[i]+1<<" ";
cout<<outp[n-1]+1<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
3760 KB |
Output is correct |
2 |
Correct |
14 ms |
3780 KB |
Output is correct |
3 |
Correct |
10 ms |
2760 KB |
Output is correct |
4 |
Correct |
22 ms |
3868 KB |
Output is correct |
5 |
Correct |
8 ms |
2760 KB |
Output is correct |
6 |
Correct |
8 ms |
2760 KB |
Output is correct |
7 |
Correct |
8 ms |
2760 KB |
Output is correct |
8 |
Correct |
8 ms |
2780 KB |
Output is correct |
9 |
Correct |
21 ms |
3868 KB |
Output is correct |
10 |
Correct |
8 ms |
2788 KB |
Output is correct |
11 |
Correct |
51 ms |
3888 KB |
Output is correct |
12 |
Correct |
19 ms |
3812 KB |
Output is correct |
13 |
Correct |
23 ms |
3888 KB |
Output is correct |
14 |
Correct |
23 ms |
3824 KB |
Output is correct |
15 |
Correct |
30 ms |
3832 KB |
Output is correct |
16 |
Correct |
10 ms |
2760 KB |
Output is correct |
17 |
Correct |
15 ms |
3888 KB |
Output is correct |
18 |
Correct |
10 ms |
2760 KB |
Output is correct |
19 |
Correct |
11 ms |
3052 KB |
Output is correct |
20 |
Correct |
11 ms |
3016 KB |
Output is correct |
21 |
Correct |
13 ms |
3016 KB |
Output is correct |
22 |
Correct |
34 ms |
5072 KB |
Output is correct |
23 |
Correct |
35 ms |
5096 KB |
Output is correct |
24 |
Correct |
51 ms |
5040 KB |
Output is correct |
25 |
Correct |
37 ms |
5036 KB |
Output is correct |
26 |
Correct |
32 ms |
5104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
191 ms |
14584 KB |
Output is correct |
2 |
Correct |
182 ms |
14700 KB |
Output is correct |
3 |
Correct |
196 ms |
16016 KB |
Output is correct |
4 |
Correct |
194 ms |
15472 KB |
Output is correct |
5 |
Correct |
204 ms |
15976 KB |
Output is correct |
6 |
Correct |
357 ms |
24936 KB |
Output is correct |
7 |
Correct |
220 ms |
17680 KB |
Output is correct |
8 |
Correct |
248 ms |
18836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
3888 KB |
Output is correct |
2 |
Correct |
211 ms |
24848 KB |
Output is correct |
3 |
Correct |
913 ms |
100512 KB |
Output is correct |
4 |
Correct |
954 ms |
95328 KB |
Output is correct |
5 |
Correct |
737 ms |
53160 KB |
Output is correct |
6 |
Correct |
296 ms |
28988 KB |
Output is correct |
7 |
Correct |
123 ms |
14744 KB |
Output is correct |
8 |
Correct |
49 ms |
6688 KB |
Output is correct |
9 |
Correct |
950 ms |
92340 KB |
Output is correct |
10 |
Correct |
719 ms |
53284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
497 ms |
89612 KB |
Output is correct |
2 |
Correct |
476 ms |
88884 KB |
Output is correct |
3 |
Correct |
294 ms |
16140 KB |
Output is correct |
4 |
Correct |
499 ms |
88900 KB |
Output is correct |
5 |
Correct |
486 ms |
88860 KB |
Output is correct |
6 |
Correct |
251 ms |
15640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
3760 KB |
Output is correct |
2 |
Correct |
14 ms |
3780 KB |
Output is correct |
3 |
Correct |
10 ms |
2760 KB |
Output is correct |
4 |
Correct |
22 ms |
3868 KB |
Output is correct |
5 |
Correct |
8 ms |
2760 KB |
Output is correct |
6 |
Correct |
8 ms |
2760 KB |
Output is correct |
7 |
Correct |
8 ms |
2760 KB |
Output is correct |
8 |
Correct |
8 ms |
2780 KB |
Output is correct |
9 |
Correct |
21 ms |
3868 KB |
Output is correct |
10 |
Correct |
8 ms |
2788 KB |
Output is correct |
11 |
Correct |
51 ms |
3888 KB |
Output is correct |
12 |
Correct |
19 ms |
3812 KB |
Output is correct |
13 |
Correct |
23 ms |
3888 KB |
Output is correct |
14 |
Correct |
23 ms |
3824 KB |
Output is correct |
15 |
Correct |
30 ms |
3832 KB |
Output is correct |
16 |
Correct |
10 ms |
2760 KB |
Output is correct |
17 |
Correct |
15 ms |
3888 KB |
Output is correct |
18 |
Correct |
10 ms |
2760 KB |
Output is correct |
19 |
Correct |
11 ms |
3052 KB |
Output is correct |
20 |
Correct |
11 ms |
3016 KB |
Output is correct |
21 |
Correct |
13 ms |
3016 KB |
Output is correct |
22 |
Correct |
34 ms |
5072 KB |
Output is correct |
23 |
Correct |
35 ms |
5096 KB |
Output is correct |
24 |
Correct |
51 ms |
5040 KB |
Output is correct |
25 |
Correct |
37 ms |
5036 KB |
Output is correct |
26 |
Correct |
32 ms |
5104 KB |
Output is correct |
27 |
Correct |
16 ms |
3264 KB |
Output is correct |
28 |
Correct |
14 ms |
3196 KB |
Output is correct |
29 |
Correct |
13 ms |
3264 KB |
Output is correct |
30 |
Correct |
40 ms |
6352 KB |
Output is correct |
31 |
Correct |
39 ms |
6300 KB |
Output is correct |
32 |
Correct |
50 ms |
6360 KB |
Output is correct |
33 |
Correct |
66 ms |
7956 KB |
Output is correct |
34 |
Correct |
69 ms |
7956 KB |
Output is correct |
35 |
Correct |
85 ms |
8920 KB |
Output is correct |
36 |
Correct |
201 ms |
24540 KB |
Output is correct |
37 |
Correct |
207 ms |
24644 KB |
Output is correct |
38 |
Correct |
207 ms |
24720 KB |
Output is correct |
39 |
Correct |
337 ms |
9980 KB |
Output is correct |
40 |
Correct |
339 ms |
9932 KB |
Output is correct |
41 |
Correct |
334 ms |
10296 KB |
Output is correct |
42 |
Correct |
136 ms |
8356 KB |
Output is correct |
43 |
Correct |
166 ms |
24676 KB |
Output is correct |
44 |
Correct |
150 ms |
25560 KB |
Output is correct |
45 |
Correct |
149 ms |
24624 KB |
Output is correct |
46 |
Correct |
154 ms |
25728 KB |
Output is correct |
47 |
Correct |
147 ms |
25472 KB |
Output is correct |
48 |
Correct |
146 ms |
24656 KB |
Output is correct |
49 |
Correct |
155 ms |
24948 KB |
Output is correct |
50 |
Correct |
149 ms |
24764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
3760 KB |
Output is correct |
2 |
Correct |
14 ms |
3780 KB |
Output is correct |
3 |
Correct |
10 ms |
2760 KB |
Output is correct |
4 |
Correct |
22 ms |
3868 KB |
Output is correct |
5 |
Correct |
8 ms |
2760 KB |
Output is correct |
6 |
Correct |
8 ms |
2760 KB |
Output is correct |
7 |
Correct |
8 ms |
2760 KB |
Output is correct |
8 |
Correct |
8 ms |
2780 KB |
Output is correct |
9 |
Correct |
21 ms |
3868 KB |
Output is correct |
10 |
Correct |
8 ms |
2788 KB |
Output is correct |
11 |
Correct |
51 ms |
3888 KB |
Output is correct |
12 |
Correct |
19 ms |
3812 KB |
Output is correct |
13 |
Correct |
23 ms |
3888 KB |
Output is correct |
14 |
Correct |
23 ms |
3824 KB |
Output is correct |
15 |
Correct |
30 ms |
3832 KB |
Output is correct |
16 |
Correct |
10 ms |
2760 KB |
Output is correct |
17 |
Correct |
15 ms |
3888 KB |
Output is correct |
18 |
Correct |
10 ms |
2760 KB |
Output is correct |
19 |
Correct |
11 ms |
3052 KB |
Output is correct |
20 |
Correct |
11 ms |
3016 KB |
Output is correct |
21 |
Correct |
13 ms |
3016 KB |
Output is correct |
22 |
Correct |
34 ms |
5072 KB |
Output is correct |
23 |
Correct |
35 ms |
5096 KB |
Output is correct |
24 |
Correct |
51 ms |
5040 KB |
Output is correct |
25 |
Correct |
37 ms |
5036 KB |
Output is correct |
26 |
Correct |
32 ms |
5104 KB |
Output is correct |
27 |
Correct |
191 ms |
14584 KB |
Output is correct |
28 |
Correct |
182 ms |
14700 KB |
Output is correct |
29 |
Correct |
196 ms |
16016 KB |
Output is correct |
30 |
Correct |
194 ms |
15472 KB |
Output is correct |
31 |
Correct |
204 ms |
15976 KB |
Output is correct |
32 |
Correct |
357 ms |
24936 KB |
Output is correct |
33 |
Correct |
220 ms |
17680 KB |
Output is correct |
34 |
Correct |
248 ms |
18836 KB |
Output is correct |
35 |
Correct |
22 ms |
3888 KB |
Output is correct |
36 |
Correct |
211 ms |
24848 KB |
Output is correct |
37 |
Correct |
913 ms |
100512 KB |
Output is correct |
38 |
Correct |
954 ms |
95328 KB |
Output is correct |
39 |
Correct |
737 ms |
53160 KB |
Output is correct |
40 |
Correct |
296 ms |
28988 KB |
Output is correct |
41 |
Correct |
123 ms |
14744 KB |
Output is correct |
42 |
Correct |
49 ms |
6688 KB |
Output is correct |
43 |
Correct |
950 ms |
92340 KB |
Output is correct |
44 |
Correct |
719 ms |
53284 KB |
Output is correct |
45 |
Correct |
497 ms |
89612 KB |
Output is correct |
46 |
Correct |
476 ms |
88884 KB |
Output is correct |
47 |
Correct |
294 ms |
16140 KB |
Output is correct |
48 |
Correct |
499 ms |
88900 KB |
Output is correct |
49 |
Correct |
486 ms |
88860 KB |
Output is correct |
50 |
Correct |
251 ms |
15640 KB |
Output is correct |
51 |
Correct |
16 ms |
3264 KB |
Output is correct |
52 |
Correct |
14 ms |
3196 KB |
Output is correct |
53 |
Correct |
13 ms |
3264 KB |
Output is correct |
54 |
Correct |
40 ms |
6352 KB |
Output is correct |
55 |
Correct |
39 ms |
6300 KB |
Output is correct |
56 |
Correct |
50 ms |
6360 KB |
Output is correct |
57 |
Correct |
66 ms |
7956 KB |
Output is correct |
58 |
Correct |
69 ms |
7956 KB |
Output is correct |
59 |
Correct |
85 ms |
8920 KB |
Output is correct |
60 |
Correct |
201 ms |
24540 KB |
Output is correct |
61 |
Correct |
207 ms |
24644 KB |
Output is correct |
62 |
Correct |
207 ms |
24720 KB |
Output is correct |
63 |
Correct |
337 ms |
9980 KB |
Output is correct |
64 |
Correct |
339 ms |
9932 KB |
Output is correct |
65 |
Correct |
334 ms |
10296 KB |
Output is correct |
66 |
Correct |
136 ms |
8356 KB |
Output is correct |
67 |
Correct |
166 ms |
24676 KB |
Output is correct |
68 |
Correct |
150 ms |
25560 KB |
Output is correct |
69 |
Correct |
149 ms |
24624 KB |
Output is correct |
70 |
Correct |
154 ms |
25728 KB |
Output is correct |
71 |
Correct |
147 ms |
25472 KB |
Output is correct |
72 |
Correct |
146 ms |
24656 KB |
Output is correct |
73 |
Correct |
155 ms |
24948 KB |
Output is correct |
74 |
Correct |
149 ms |
24764 KB |
Output is correct |
75 |
Correct |
208 ms |
14028 KB |
Output is correct |
76 |
Correct |
214 ms |
15328 KB |
Output is correct |
77 |
Correct |
204 ms |
17424 KB |
Output is correct |
78 |
Correct |
193 ms |
15232 KB |
Output is correct |
79 |
Correct |
263 ms |
15984 KB |
Output is correct |
80 |
Correct |
186 ms |
15160 KB |
Output is correct |
81 |
Correct |
808 ms |
88988 KB |
Output is correct |
82 |
Correct |
806 ms |
88920 KB |
Output is correct |
83 |
Correct |
968 ms |
92164 KB |
Output is correct |
84 |
Correct |
957 ms |
99800 KB |
Output is correct |
85 |
Correct |
946 ms |
92068 KB |
Output is correct |
86 |
Correct |
851 ms |
88892 KB |
Output is correct |
87 |
Correct |
920 ms |
92040 KB |
Output is correct |
88 |
Correct |
545 ms |
23520 KB |
Output is correct |
89 |
Correct |
552 ms |
23476 KB |
Output is correct |
90 |
Correct |
594 ms |
23440 KB |
Output is correct |
91 |
Correct |
600 ms |
23540 KB |
Output is correct |
92 |
Correct |
575 ms |
23472 KB |
Output is correct |
93 |
Correct |
673 ms |
88168 KB |
Output is correct |
94 |
Correct |
776 ms |
88140 KB |
Output is correct |
95 |
Correct |
676 ms |
88096 KB |
Output is correct |
96 |
Correct |
735 ms |
88128 KB |
Output is correct |
97 |
Correct |
718 ms |
88056 KB |
Output is correct |
98 |
Correct |
406 ms |
23692 KB |
Output is correct |
99 |
Correct |
888 ms |
91348 KB |
Output is correct |
100 |
Correct |
624 ms |
88152 KB |
Output is correct |
101 |
Correct |
588 ms |
33336 KB |
Output is correct |
102 |
Correct |
769 ms |
53284 KB |
Output is correct |
103 |
Correct |
707 ms |
52320 KB |
Output is correct |
104 |
Correct |
823 ms |
88152 KB |
Output is correct |
105 |
Correct |
432 ms |
16920 KB |
Output is correct |
106 |
Correct |
471 ms |
52236 KB |
Output is correct |
107 |
Correct |
512 ms |
52264 KB |
Output is correct |
108 |
Correct |
486 ms |
52308 KB |
Output is correct |
109 |
Correct |
462 ms |
52300 KB |
Output is correct |
110 |
Correct |
479 ms |
52260 KB |
Output is correct |
111 |
Correct |
503 ms |
52404 KB |
Output is correct |
112 |
Correct |
459 ms |
52296 KB |
Output is correct |
113 |
Correct |
519 ms |
52260 KB |
Output is correct |
114 |
Correct |
491 ms |
52260 KB |
Output is correct |
115 |
Correct |
484 ms |
52264 KB |
Output is correct |
116 |
Correct |
484 ms |
52280 KB |
Output is correct |