#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 300005
#define int int64_t
inline int hh(int x,int y){
return x*2000000007 + y;
}
int n;
bitset<N> gg;
unordered_map<int,vector<int> > mp;
int nb,ans[N],xx[N],yy[N],rr[N];
vector<int> ord;
void build(){
mp.clear();
for(int i=0;i<n;i++) if(!gg[i]){
int t = hh(xx[i]/nb,yy[i]/nb);
mp[t].push_back(i);
}
}
bool cov(int i,int j){
return (xx[i]-xx[j])*(xx[i]-xx[j]) + (yy[i]-yy[j])*(yy[i]-yy[j]) <= (rr[i]+rr[j])*(rr[i]+rr[j]);
}
void qur(int x){
int bx = xx[x]/nb, by = yy[x]/nb;
ans[x] = x; gg[x] = 1;
for(int i=bx-2;i<=bx+2;i++) for(int j=by-2;j<=by+2;j++){
auto it = mp.find(hh(i,j));
if(it != mp.end()) for(int k : it->second) if(!gg[k] && cov(k,x)){
ans[k] = x;
gg[k] = 1;
}
}
}
int32_t main()
{
IOS;
cin >> n;
int mnx,mny; mnx = mny = 1ll<<60;
ord.resize(n);
for(int i=0;i<n;i++) {
cin >> xx[i] >> yy[i] >> rr[i];
mnx = min(mnx,xx[i]);
mny = min(mny,yy[i]);
ord[i] = i;
}
for(int i=0;i<n;i++){
xx[i] = xx[i] - mnx + 1;
yy[i] = yy[i] - mny + 1;
}
stable_sort(ord.begin(),ord.end(),[](int x,int y){return rr[x] > rr[y];});
nb = 1 << __lg(2*rr[ord[0]]-1);
build();
for(int i : ord) if(!gg[i]){
while(rr[i] <= (nb>>1)) nb>>=1,build();
qur(i);
}
for(int i=0;i<n;i++) cout << ans[i]+1 << ' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 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 |
2 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 |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
768 KB |
Output is correct |
20 |
Correct |
5 ms |
640 KB |
Output is correct |
21 |
Correct |
7 ms |
768 KB |
Output is correct |
22 |
Correct |
15 ms |
1024 KB |
Output is correct |
23 |
Correct |
12 ms |
1024 KB |
Output is correct |
24 |
Correct |
10 ms |
1024 KB |
Output is correct |
25 |
Correct |
11 ms |
1024 KB |
Output is correct |
26 |
Correct |
12 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
228 ms |
18448 KB |
Output is correct |
2 |
Correct |
201 ms |
17768 KB |
Output is correct |
3 |
Correct |
266 ms |
19036 KB |
Output is correct |
4 |
Correct |
183 ms |
18272 KB |
Output is correct |
5 |
Correct |
278 ms |
18116 KB |
Output is correct |
6 |
Correct |
950 ms |
31148 KB |
Output is correct |
7 |
Correct |
377 ms |
23856 KB |
Output is correct |
8 |
Correct |
405 ms |
25636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
476 ms |
13652 KB |
Output is correct |
3 |
Correct |
1737 ms |
41200 KB |
Output is correct |
4 |
Correct |
1826 ms |
41148 KB |
Output is correct |
5 |
Correct |
1947 ms |
37056 KB |
Output is correct |
6 |
Correct |
669 ms |
22932 KB |
Output is correct |
7 |
Correct |
256 ms |
12316 KB |
Output is correct |
8 |
Correct |
42 ms |
2872 KB |
Output is correct |
9 |
Correct |
1984 ms |
48452 KB |
Output is correct |
10 |
Correct |
1531 ms |
44844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2052 ms |
41228 KB |
Output is correct |
2 |
Correct |
1981 ms |
48144 KB |
Output is correct |
3 |
Correct |
442 ms |
30944 KB |
Output is correct |
4 |
Correct |
1959 ms |
48604 KB |
Output is correct |
5 |
Correct |
1833 ms |
48740 KB |
Output is correct |
6 |
Correct |
395 ms |
27104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 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 |
2 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 |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
768 KB |
Output is correct |
20 |
Correct |
5 ms |
640 KB |
Output is correct |
21 |
Correct |
7 ms |
768 KB |
Output is correct |
22 |
Correct |
15 ms |
1024 KB |
Output is correct |
23 |
Correct |
12 ms |
1024 KB |
Output is correct |
24 |
Correct |
10 ms |
1024 KB |
Output is correct |
25 |
Correct |
11 ms |
1024 KB |
Output is correct |
26 |
Correct |
12 ms |
1024 KB |
Output is correct |
27 |
Correct |
8 ms |
1024 KB |
Output is correct |
28 |
Correct |
8 ms |
1024 KB |
Output is correct |
29 |
Correct |
12 ms |
1024 KB |
Output is correct |
30 |
Correct |
27 ms |
1784 KB |
Output is correct |
31 |
Correct |
25 ms |
1664 KB |
Output is correct |
32 |
Correct |
24 ms |
1664 KB |
Output is correct |
33 |
Correct |
67 ms |
6768 KB |
Output is correct |
34 |
Correct |
66 ms |
6768 KB |
Output is correct |
35 |
Correct |
72 ms |
5872 KB |
Output is correct |
36 |
Correct |
575 ms |
13540 KB |
Output is correct |
37 |
Correct |
558 ms |
13676 KB |
Output is correct |
38 |
Correct |
588 ms |
13676 KB |
Output is correct |
39 |
Correct |
541 ms |
12552 KB |
Output is correct |
40 |
Correct |
580 ms |
13540 KB |
Output is correct |
41 |
Correct |
625 ms |
13684 KB |
Output is correct |
42 |
Correct |
240 ms |
12144 KB |
Output is correct |
43 |
Correct |
580 ms |
15980 KB |
Output is correct |
44 |
Correct |
535 ms |
15980 KB |
Output is correct |
45 |
Correct |
559 ms |
15980 KB |
Output is correct |
46 |
Correct |
566 ms |
16112 KB |
Output is correct |
47 |
Correct |
616 ms |
16112 KB |
Output is correct |
48 |
Correct |
597 ms |
15984 KB |
Output is correct |
49 |
Correct |
550 ms |
15996 KB |
Output is correct |
50 |
Correct |
591 ms |
15988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 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 |
2 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 |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
768 KB |
Output is correct |
20 |
Correct |
5 ms |
640 KB |
Output is correct |
21 |
Correct |
7 ms |
768 KB |
Output is correct |
22 |
Correct |
15 ms |
1024 KB |
Output is correct |
23 |
Correct |
12 ms |
1024 KB |
Output is correct |
24 |
Correct |
10 ms |
1024 KB |
Output is correct |
25 |
Correct |
11 ms |
1024 KB |
Output is correct |
26 |
Correct |
12 ms |
1024 KB |
Output is correct |
27 |
Correct |
228 ms |
18448 KB |
Output is correct |
28 |
Correct |
201 ms |
17768 KB |
Output is correct |
29 |
Correct |
266 ms |
19036 KB |
Output is correct |
30 |
Correct |
183 ms |
18272 KB |
Output is correct |
31 |
Correct |
278 ms |
18116 KB |
Output is correct |
32 |
Correct |
950 ms |
31148 KB |
Output is correct |
33 |
Correct |
377 ms |
23856 KB |
Output is correct |
34 |
Correct |
405 ms |
25636 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
476 ms |
13652 KB |
Output is correct |
37 |
Correct |
1737 ms |
41200 KB |
Output is correct |
38 |
Correct |
1826 ms |
41148 KB |
Output is correct |
39 |
Correct |
1947 ms |
37056 KB |
Output is correct |
40 |
Correct |
669 ms |
22932 KB |
Output is correct |
41 |
Correct |
256 ms |
12316 KB |
Output is correct |
42 |
Correct |
42 ms |
2872 KB |
Output is correct |
43 |
Correct |
1984 ms |
48452 KB |
Output is correct |
44 |
Correct |
1531 ms |
44844 KB |
Output is correct |
45 |
Correct |
2052 ms |
41228 KB |
Output is correct |
46 |
Correct |
1981 ms |
48144 KB |
Output is correct |
47 |
Correct |
442 ms |
30944 KB |
Output is correct |
48 |
Correct |
1959 ms |
48604 KB |
Output is correct |
49 |
Correct |
1833 ms |
48740 KB |
Output is correct |
50 |
Correct |
395 ms |
27104 KB |
Output is correct |
51 |
Correct |
8 ms |
1024 KB |
Output is correct |
52 |
Correct |
8 ms |
1024 KB |
Output is correct |
53 |
Correct |
12 ms |
1024 KB |
Output is correct |
54 |
Correct |
27 ms |
1784 KB |
Output is correct |
55 |
Correct |
25 ms |
1664 KB |
Output is correct |
56 |
Correct |
24 ms |
1664 KB |
Output is correct |
57 |
Correct |
67 ms |
6768 KB |
Output is correct |
58 |
Correct |
66 ms |
6768 KB |
Output is correct |
59 |
Correct |
72 ms |
5872 KB |
Output is correct |
60 |
Correct |
575 ms |
13540 KB |
Output is correct |
61 |
Correct |
558 ms |
13676 KB |
Output is correct |
62 |
Correct |
588 ms |
13676 KB |
Output is correct |
63 |
Correct |
541 ms |
12552 KB |
Output is correct |
64 |
Correct |
580 ms |
13540 KB |
Output is correct |
65 |
Correct |
625 ms |
13684 KB |
Output is correct |
66 |
Correct |
240 ms |
12144 KB |
Output is correct |
67 |
Correct |
580 ms |
15980 KB |
Output is correct |
68 |
Correct |
535 ms |
15980 KB |
Output is correct |
69 |
Correct |
559 ms |
15980 KB |
Output is correct |
70 |
Correct |
566 ms |
16112 KB |
Output is correct |
71 |
Correct |
616 ms |
16112 KB |
Output is correct |
72 |
Correct |
597 ms |
15984 KB |
Output is correct |
73 |
Correct |
550 ms |
15996 KB |
Output is correct |
74 |
Correct |
591 ms |
15988 KB |
Output is correct |
75 |
Correct |
224 ms |
26144 KB |
Output is correct |
76 |
Correct |
249 ms |
26592 KB |
Output is correct |
77 |
Correct |
248 ms |
29616 KB |
Output is correct |
78 |
Correct |
220 ms |
29408 KB |
Output is correct |
79 |
Correct |
350 ms |
26336 KB |
Output is correct |
80 |
Correct |
250 ms |
29308 KB |
Output is correct |
81 |
Correct |
2040 ms |
49120 KB |
Output is correct |
82 |
Correct |
1861 ms |
48996 KB |
Output is correct |
83 |
Correct |
1826 ms |
49164 KB |
Output is correct |
84 |
Correct |
1788 ms |
49504 KB |
Output is correct |
85 |
Correct |
1822 ms |
49120 KB |
Output is correct |
86 |
Correct |
1825 ms |
49144 KB |
Output is correct |
87 |
Correct |
1855 ms |
49000 KB |
Output is correct |
88 |
Correct |
2120 ms |
41384 KB |
Output is correct |
89 |
Correct |
2198 ms |
41364 KB |
Output is correct |
90 |
Correct |
2180 ms |
41376 KB |
Output is correct |
91 |
Correct |
2049 ms |
41524 KB |
Output is correct |
92 |
Correct |
1926 ms |
41464 KB |
Output is correct |
93 |
Correct |
1854 ms |
48108 KB |
Output is correct |
94 |
Correct |
1770 ms |
48208 KB |
Output is correct |
95 |
Correct |
1859 ms |
48100 KB |
Output is correct |
96 |
Correct |
1738 ms |
48148 KB |
Output is correct |
97 |
Correct |
1769 ms |
48056 KB |
Output is correct |
98 |
Correct |
1012 ms |
32008 KB |
Output is correct |
99 |
Correct |
1740 ms |
48376 KB |
Output is correct |
100 |
Correct |
1678 ms |
48124 KB |
Output is correct |
101 |
Correct |
1701 ms |
38624 KB |
Output is correct |
102 |
Correct |
1717 ms |
47468 KB |
Output is correct |
103 |
Correct |
1889 ms |
46936 KB |
Output is correct |
104 |
Correct |
1935 ms |
48052 KB |
Output is correct |
105 |
Correct |
1071 ms |
35168 KB |
Output is correct |
106 |
Correct |
1487 ms |
47320 KB |
Output is correct |
107 |
Correct |
1531 ms |
47312 KB |
Output is correct |
108 |
Correct |
1632 ms |
47156 KB |
Output is correct |
109 |
Correct |
1759 ms |
47456 KB |
Output is correct |
110 |
Correct |
1565 ms |
47348 KB |
Output is correct |
111 |
Correct |
1485 ms |
47328 KB |
Output is correct |
112 |
Correct |
1483 ms |
47180 KB |
Output is correct |
113 |
Correct |
1429 ms |
47220 KB |
Output is correct |
114 |
Correct |
1484 ms |
47200 KB |
Output is correct |
115 |
Correct |
1772 ms |
47428 KB |
Output is correct |
116 |
Correct |
1635 ms |
47436 KB |
Output is correct |