#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pp;
const int MAXN=300000;
const int rnd=1e9+7;
const int base=1000003;
bool vis[MAXN];
int n,cr,outp[MAXN],inp[MAXN][3];
pp take[MAXN];
vector<int>plane[base],reset;
int cmp(int a,int b){
return abs((a*rnd+b)%base);
}
void create(){
for(int i:reset)plane[i].clear();
reset.clear();
for(pp i:take){
if(vis[i.second])continue;
int h=cmp(inp[i.second][0]>>cr,inp[i.second][1]>>cr);
if(plane[h].size()==0)reset.push_back(h);
plane[h].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++){
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 |
32 ms |
28316 KB |
Output is correct |
2 |
Correct |
29 ms |
28332 KB |
Output is correct |
3 |
Correct |
23 ms |
26204 KB |
Output is correct |
4 |
Correct |
37 ms |
29504 KB |
Output is correct |
5 |
Correct |
23 ms |
26272 KB |
Output is correct |
6 |
Correct |
24 ms |
26272 KB |
Output is correct |
7 |
Correct |
23 ms |
26224 KB |
Output is correct |
8 |
Correct |
22 ms |
26312 KB |
Output is correct |
9 |
Correct |
38 ms |
29484 KB |
Output is correct |
10 |
Correct |
22 ms |
26312 KB |
Output is correct |
11 |
Correct |
70 ms |
35320 KB |
Output is correct |
12 |
Correct |
32 ms |
28344 KB |
Output is correct |
13 |
Correct |
38 ms |
29532 KB |
Output is correct |
14 |
Correct |
37 ms |
29472 KB |
Output is correct |
15 |
Correct |
45 ms |
30740 KB |
Output is correct |
16 |
Correct |
25 ms |
26364 KB |
Output is correct |
17 |
Correct |
36 ms |
28348 KB |
Output is correct |
18 |
Correct |
23 ms |
26312 KB |
Output is correct |
19 |
Correct |
25 ms |
26488 KB |
Output is correct |
20 |
Correct |
28 ms |
26440 KB |
Output is correct |
21 |
Correct |
29 ms |
26516 KB |
Output is correct |
22 |
Correct |
51 ms |
29976 KB |
Output is correct |
23 |
Correct |
48 ms |
30012 KB |
Output is correct |
24 |
Correct |
64 ms |
33636 KB |
Output is correct |
25 |
Correct |
55 ms |
31324 KB |
Output is correct |
26 |
Correct |
49 ms |
30156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
205 ms |
41344 KB |
Output is correct |
2 |
Correct |
220 ms |
41236 KB |
Output is correct |
3 |
Correct |
230 ms |
41260 KB |
Output is correct |
4 |
Correct |
197 ms |
41660 KB |
Output is correct |
5 |
Correct |
241 ms |
40700 KB |
Output is correct |
6 |
Correct |
403 ms |
43196 KB |
Output is correct |
7 |
Correct |
281 ms |
41236 KB |
Output is correct |
8 |
Correct |
307 ms |
42168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
28316 KB |
Output is correct |
2 |
Correct |
212 ms |
38124 KB |
Output is correct |
3 |
Correct |
830 ms |
61324 KB |
Output is correct |
4 |
Correct |
900 ms |
61596 KB |
Output is correct |
5 |
Correct |
857 ms |
56816 KB |
Output is correct |
6 |
Correct |
300 ms |
42284 KB |
Output is correct |
7 |
Correct |
139 ms |
34488 KB |
Output is correct |
8 |
Correct |
63 ms |
32064 KB |
Output is correct |
9 |
Correct |
980 ms |
62884 KB |
Output is correct |
10 |
Correct |
707 ms |
53916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
495 ms |
51324 KB |
Output is correct |
2 |
Correct |
457 ms |
50420 KB |
Output is correct |
3 |
Correct |
287 ms |
44460 KB |
Output is correct |
4 |
Correct |
490 ms |
50888 KB |
Output is correct |
5 |
Correct |
479 ms |
50988 KB |
Output is correct |
6 |
Correct |
271 ms |
44420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
28316 KB |
Output is correct |
2 |
Correct |
29 ms |
28332 KB |
Output is correct |
3 |
Correct |
23 ms |
26204 KB |
Output is correct |
4 |
Correct |
37 ms |
29504 KB |
Output is correct |
5 |
Correct |
23 ms |
26272 KB |
Output is correct |
6 |
Correct |
24 ms |
26272 KB |
Output is correct |
7 |
Correct |
23 ms |
26224 KB |
Output is correct |
8 |
Correct |
22 ms |
26312 KB |
Output is correct |
9 |
Correct |
38 ms |
29484 KB |
Output is correct |
10 |
Correct |
22 ms |
26312 KB |
Output is correct |
11 |
Correct |
70 ms |
35320 KB |
Output is correct |
12 |
Correct |
32 ms |
28344 KB |
Output is correct |
13 |
Correct |
38 ms |
29532 KB |
Output is correct |
14 |
Correct |
37 ms |
29472 KB |
Output is correct |
15 |
Correct |
45 ms |
30740 KB |
Output is correct |
16 |
Correct |
25 ms |
26364 KB |
Output is correct |
17 |
Correct |
36 ms |
28348 KB |
Output is correct |
18 |
Correct |
23 ms |
26312 KB |
Output is correct |
19 |
Correct |
25 ms |
26488 KB |
Output is correct |
20 |
Correct |
28 ms |
26440 KB |
Output is correct |
21 |
Correct |
29 ms |
26516 KB |
Output is correct |
22 |
Correct |
51 ms |
29976 KB |
Output is correct |
23 |
Correct |
48 ms |
30012 KB |
Output is correct |
24 |
Correct |
64 ms |
33636 KB |
Output is correct |
25 |
Correct |
55 ms |
31324 KB |
Output is correct |
26 |
Correct |
49 ms |
30156 KB |
Output is correct |
27 |
Correct |
30 ms |
26816 KB |
Output is correct |
28 |
Correct |
28 ms |
26728 KB |
Output is correct |
29 |
Correct |
28 ms |
26808 KB |
Output is correct |
30 |
Correct |
58 ms |
30536 KB |
Output is correct |
31 |
Correct |
59 ms |
30568 KB |
Output is correct |
32 |
Correct |
61 ms |
31892 KB |
Output is correct |
33 |
Correct |
79 ms |
31412 KB |
Output is correct |
34 |
Correct |
86 ms |
31420 KB |
Output is correct |
35 |
Correct |
110 ms |
31452 KB |
Output is correct |
36 |
Correct |
230 ms |
38100 KB |
Output is correct |
37 |
Correct |
258 ms |
41092 KB |
Output is correct |
38 |
Correct |
239 ms |
40224 KB |
Output is correct |
39 |
Correct |
391 ms |
31044 KB |
Output is correct |
40 |
Correct |
368 ms |
31092 KB |
Output is correct |
41 |
Correct |
377 ms |
31060 KB |
Output is correct |
42 |
Correct |
120 ms |
32172 KB |
Output is correct |
43 |
Correct |
170 ms |
34332 KB |
Output is correct |
44 |
Correct |
166 ms |
34628 KB |
Output is correct |
45 |
Correct |
173 ms |
35084 KB |
Output is correct |
46 |
Correct |
204 ms |
34544 KB |
Output is correct |
47 |
Correct |
171 ms |
33896 KB |
Output is correct |
48 |
Correct |
147 ms |
34648 KB |
Output is correct |
49 |
Correct |
178 ms |
34600 KB |
Output is correct |
50 |
Correct |
153 ms |
34532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
28316 KB |
Output is correct |
2 |
Correct |
29 ms |
28332 KB |
Output is correct |
3 |
Correct |
23 ms |
26204 KB |
Output is correct |
4 |
Correct |
37 ms |
29504 KB |
Output is correct |
5 |
Correct |
23 ms |
26272 KB |
Output is correct |
6 |
Correct |
24 ms |
26272 KB |
Output is correct |
7 |
Correct |
23 ms |
26224 KB |
Output is correct |
8 |
Correct |
22 ms |
26312 KB |
Output is correct |
9 |
Correct |
38 ms |
29484 KB |
Output is correct |
10 |
Correct |
22 ms |
26312 KB |
Output is correct |
11 |
Correct |
70 ms |
35320 KB |
Output is correct |
12 |
Correct |
32 ms |
28344 KB |
Output is correct |
13 |
Correct |
38 ms |
29532 KB |
Output is correct |
14 |
Correct |
37 ms |
29472 KB |
Output is correct |
15 |
Correct |
45 ms |
30740 KB |
Output is correct |
16 |
Correct |
25 ms |
26364 KB |
Output is correct |
17 |
Correct |
36 ms |
28348 KB |
Output is correct |
18 |
Correct |
23 ms |
26312 KB |
Output is correct |
19 |
Correct |
25 ms |
26488 KB |
Output is correct |
20 |
Correct |
28 ms |
26440 KB |
Output is correct |
21 |
Correct |
29 ms |
26516 KB |
Output is correct |
22 |
Correct |
51 ms |
29976 KB |
Output is correct |
23 |
Correct |
48 ms |
30012 KB |
Output is correct |
24 |
Correct |
64 ms |
33636 KB |
Output is correct |
25 |
Correct |
55 ms |
31324 KB |
Output is correct |
26 |
Correct |
49 ms |
30156 KB |
Output is correct |
27 |
Correct |
205 ms |
41344 KB |
Output is correct |
28 |
Correct |
220 ms |
41236 KB |
Output is correct |
29 |
Correct |
230 ms |
41260 KB |
Output is correct |
30 |
Correct |
197 ms |
41660 KB |
Output is correct |
31 |
Correct |
241 ms |
40700 KB |
Output is correct |
32 |
Correct |
403 ms |
43196 KB |
Output is correct |
33 |
Correct |
281 ms |
41236 KB |
Output is correct |
34 |
Correct |
307 ms |
42168 KB |
Output is correct |
35 |
Correct |
38 ms |
28316 KB |
Output is correct |
36 |
Correct |
212 ms |
38124 KB |
Output is correct |
37 |
Correct |
830 ms |
61324 KB |
Output is correct |
38 |
Correct |
900 ms |
61596 KB |
Output is correct |
39 |
Correct |
857 ms |
56816 KB |
Output is correct |
40 |
Correct |
300 ms |
42284 KB |
Output is correct |
41 |
Correct |
139 ms |
34488 KB |
Output is correct |
42 |
Correct |
63 ms |
32064 KB |
Output is correct |
43 |
Correct |
980 ms |
62884 KB |
Output is correct |
44 |
Correct |
707 ms |
53916 KB |
Output is correct |
45 |
Correct |
495 ms |
51324 KB |
Output is correct |
46 |
Correct |
457 ms |
50420 KB |
Output is correct |
47 |
Correct |
287 ms |
44460 KB |
Output is correct |
48 |
Correct |
490 ms |
50888 KB |
Output is correct |
49 |
Correct |
479 ms |
50988 KB |
Output is correct |
50 |
Correct |
271 ms |
44420 KB |
Output is correct |
51 |
Correct |
30 ms |
26816 KB |
Output is correct |
52 |
Correct |
28 ms |
26728 KB |
Output is correct |
53 |
Correct |
28 ms |
26808 KB |
Output is correct |
54 |
Correct |
58 ms |
30536 KB |
Output is correct |
55 |
Correct |
59 ms |
30568 KB |
Output is correct |
56 |
Correct |
61 ms |
31892 KB |
Output is correct |
57 |
Correct |
79 ms |
31412 KB |
Output is correct |
58 |
Correct |
86 ms |
31420 KB |
Output is correct |
59 |
Correct |
110 ms |
31452 KB |
Output is correct |
60 |
Correct |
230 ms |
38100 KB |
Output is correct |
61 |
Correct |
258 ms |
41092 KB |
Output is correct |
62 |
Correct |
239 ms |
40224 KB |
Output is correct |
63 |
Correct |
391 ms |
31044 KB |
Output is correct |
64 |
Correct |
368 ms |
31092 KB |
Output is correct |
65 |
Correct |
377 ms |
31060 KB |
Output is correct |
66 |
Correct |
120 ms |
32172 KB |
Output is correct |
67 |
Correct |
170 ms |
34332 KB |
Output is correct |
68 |
Correct |
166 ms |
34628 KB |
Output is correct |
69 |
Correct |
173 ms |
35084 KB |
Output is correct |
70 |
Correct |
204 ms |
34544 KB |
Output is correct |
71 |
Correct |
171 ms |
33896 KB |
Output is correct |
72 |
Correct |
147 ms |
34648 KB |
Output is correct |
73 |
Correct |
178 ms |
34600 KB |
Output is correct |
74 |
Correct |
153 ms |
34532 KB |
Output is correct |
75 |
Correct |
222 ms |
43544 KB |
Output is correct |
76 |
Correct |
236 ms |
44444 KB |
Output is correct |
77 |
Correct |
224 ms |
44612 KB |
Output is correct |
78 |
Correct |
204 ms |
43192 KB |
Output is correct |
79 |
Correct |
282 ms |
44904 KB |
Output is correct |
80 |
Correct |
255 ms |
43192 KB |
Output is correct |
81 |
Correct |
755 ms |
59160 KB |
Output is correct |
82 |
Correct |
773 ms |
59780 KB |
Output is correct |
83 |
Correct |
829 ms |
61644 KB |
Output is correct |
84 |
Correct |
811 ms |
61612 KB |
Output is correct |
85 |
Correct |
883 ms |
60744 KB |
Output is correct |
86 |
Correct |
850 ms |
60144 KB |
Output is correct |
87 |
Correct |
874 ms |
60832 KB |
Output is correct |
88 |
Correct |
640 ms |
39984 KB |
Output is correct |
89 |
Correct |
646 ms |
40048 KB |
Output is correct |
90 |
Correct |
624 ms |
39960 KB |
Output is correct |
91 |
Correct |
666 ms |
40036 KB |
Output is correct |
92 |
Correct |
642 ms |
40036 KB |
Output is correct |
93 |
Correct |
717 ms |
55792 KB |
Output is correct |
94 |
Correct |
699 ms |
58936 KB |
Output is correct |
95 |
Correct |
624 ms |
56280 KB |
Output is correct |
96 |
Correct |
706 ms |
57680 KB |
Output is correct |
97 |
Correct |
653 ms |
58496 KB |
Output is correct |
98 |
Correct |
472 ms |
47544 KB |
Output is correct |
99 |
Correct |
851 ms |
60172 KB |
Output is correct |
100 |
Correct |
571 ms |
54900 KB |
Output is correct |
101 |
Correct |
626 ms |
49844 KB |
Output is correct |
102 |
Correct |
731 ms |
57576 KB |
Output is correct |
103 |
Correct |
708 ms |
57280 KB |
Output is correct |
104 |
Correct |
749 ms |
58584 KB |
Output is correct |
105 |
Correct |
341 ms |
40908 KB |
Output is correct |
106 |
Correct |
530 ms |
48808 KB |
Output is correct |
107 |
Correct |
458 ms |
49476 KB |
Output is correct |
108 |
Correct |
487 ms |
49460 KB |
Output is correct |
109 |
Correct |
463 ms |
49036 KB |
Output is correct |
110 |
Correct |
509 ms |
48884 KB |
Output is correct |
111 |
Correct |
566 ms |
48372 KB |
Output is correct |
112 |
Correct |
502 ms |
47620 KB |
Output is correct |
113 |
Correct |
485 ms |
49360 KB |
Output is correct |
114 |
Correct |
461 ms |
49492 KB |
Output is correct |
115 |
Correct |
473 ms |
49236 KB |
Output is correct |
116 |
Correct |
474 ms |
49292 KB |
Output is correct |