#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)3e5 + 10;
ll cut = (1ll << 31);
int sol[N];
ll xi[N];
ll yi[N];
ll ri[N];
ll sq(ll v){
return v * 1ll * v;
}
bool check(int i, int j){
// sqrt((xi-xj)^2+(yi-yj)^2) <= (ri + rj)
ll val = sq(xi[i] - xi[j]) + sq(yi[i] - yi[j]);
ll cmp = sq(ri[i] + ri[j]);
if(val <= cmp)
return true;
return false;
}
int main(){
fastIO;
int n;
cin >> n;
vector<pii> cir;
for(int i = 1; i <= n; i ++ ){
cin >> xi[i] >> yi[i] >> ri[i];
cir.push_back({ri[i], -i});
}
sort(cir.begin(), cir.end());
int id;
bool has;
ll ci, cj;
int gg;
set<pair<pii,int>> cv;
for(int i = cir.size() - 1; i >= 0 ;i -- ){
id = -cir[i].se;
if(sol[id] == 0){
has=false;
while(cut/2ll >= ri[id]){
has=true;
cut /= 2ll;
}
if(has){
cv.clear();
for(int i = 1; i <= n; i ++ ){
if(sol[i] == 0){
cv.insert(mp(mp(xi[i]/cut,yi[i]/cut),i));
}
}
}
ci = xi[id]/cut;
cj = yi[id]/cut;
for(ll p = -2; p <= 2; p ++ ){
auto it = cv.lower_bound({mp(ci-p,cj-2),-1});
while(it != cv.end()){
if((it->fi).fi != ci - p) break;
if((it->fi).se > cj + 2) break;
gg = it->se;
if(check(gg, id)){
sol[gg] = id;
it=cv.erase(it);
}
else{
it++;
}
}
}
}
}
for(int i = 1; i <= n; i ++ ){
cout << sol[i] << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
5 ms |
1132 KB |
Output is correct |
20 |
Correct |
6 ms |
1260 KB |
Output is correct |
21 |
Correct |
5 ms |
1132 KB |
Output is correct |
22 |
Correct |
8 ms |
1004 KB |
Output is correct |
23 |
Correct |
10 ms |
1004 KB |
Output is correct |
24 |
Correct |
9 ms |
1132 KB |
Output is correct |
25 |
Correct |
10 ms |
1132 KB |
Output is correct |
26 |
Correct |
9 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
34904 KB |
Output is correct |
2 |
Correct |
262 ms |
34896 KB |
Output is correct |
3 |
Correct |
237 ms |
34512 KB |
Output is correct |
4 |
Correct |
262 ms |
34900 KB |
Output is correct |
5 |
Correct |
498 ms |
34648 KB |
Output is correct |
6 |
Correct |
702 ms |
34752 KB |
Output is correct |
7 |
Correct |
554 ms |
34940 KB |
Output is correct |
8 |
Correct |
563 ms |
34768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
346 ms |
12260 KB |
Output is correct |
3 |
Correct |
1446 ms |
34916 KB |
Output is correct |
4 |
Correct |
1478 ms |
34740 KB |
Output is correct |
5 |
Correct |
1628 ms |
33860 KB |
Output is correct |
6 |
Correct |
557 ms |
18652 KB |
Output is correct |
7 |
Correct |
192 ms |
10212 KB |
Output is correct |
8 |
Correct |
23 ms |
2668 KB |
Output is correct |
9 |
Correct |
1742 ms |
34860 KB |
Output is correct |
10 |
Correct |
1487 ms |
35056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
917 ms |
34888 KB |
Output is correct |
2 |
Correct |
680 ms |
34768 KB |
Output is correct |
3 |
Correct |
542 ms |
34320 KB |
Output is correct |
4 |
Correct |
693 ms |
34768 KB |
Output is correct |
5 |
Correct |
674 ms |
34768 KB |
Output is correct |
6 |
Correct |
511 ms |
34128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
5 ms |
1132 KB |
Output is correct |
20 |
Correct |
6 ms |
1260 KB |
Output is correct |
21 |
Correct |
5 ms |
1132 KB |
Output is correct |
22 |
Correct |
8 ms |
1004 KB |
Output is correct |
23 |
Correct |
10 ms |
1004 KB |
Output is correct |
24 |
Correct |
9 ms |
1132 KB |
Output is correct |
25 |
Correct |
10 ms |
1132 KB |
Output is correct |
26 |
Correct |
9 ms |
1004 KB |
Output is correct |
27 |
Correct |
8 ms |
1776 KB |
Output is correct |
28 |
Correct |
8 ms |
1776 KB |
Output is correct |
29 |
Correct |
8 ms |
1776 KB |
Output is correct |
30 |
Correct |
18 ms |
1776 KB |
Output is correct |
31 |
Correct |
19 ms |
1776 KB |
Output is correct |
32 |
Correct |
17 ms |
1776 KB |
Output is correct |
33 |
Correct |
85 ms |
12260 KB |
Output is correct |
34 |
Correct |
85 ms |
12188 KB |
Output is correct |
35 |
Correct |
87 ms |
12260 KB |
Output is correct |
36 |
Correct |
302 ms |
12268 KB |
Output is correct |
37 |
Correct |
297 ms |
12408 KB |
Output is correct |
38 |
Correct |
308 ms |
12260 KB |
Output is correct |
39 |
Correct |
837 ms |
12372 KB |
Output is correct |
40 |
Correct |
814 ms |
12260 KB |
Output is correct |
41 |
Correct |
818 ms |
12260 KB |
Output is correct |
42 |
Correct |
149 ms |
12260 KB |
Output is correct |
43 |
Correct |
157 ms |
12260 KB |
Output is correct |
44 |
Correct |
156 ms |
12260 KB |
Output is correct |
45 |
Correct |
166 ms |
12260 KB |
Output is correct |
46 |
Correct |
157 ms |
12388 KB |
Output is correct |
47 |
Correct |
157 ms |
12260 KB |
Output is correct |
48 |
Correct |
160 ms |
12260 KB |
Output is correct |
49 |
Correct |
160 ms |
12260 KB |
Output is correct |
50 |
Correct |
158 ms |
12388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
5 ms |
1132 KB |
Output is correct |
20 |
Correct |
6 ms |
1260 KB |
Output is correct |
21 |
Correct |
5 ms |
1132 KB |
Output is correct |
22 |
Correct |
8 ms |
1004 KB |
Output is correct |
23 |
Correct |
10 ms |
1004 KB |
Output is correct |
24 |
Correct |
9 ms |
1132 KB |
Output is correct |
25 |
Correct |
10 ms |
1132 KB |
Output is correct |
26 |
Correct |
9 ms |
1004 KB |
Output is correct |
27 |
Correct |
255 ms |
34904 KB |
Output is correct |
28 |
Correct |
262 ms |
34896 KB |
Output is correct |
29 |
Correct |
237 ms |
34512 KB |
Output is correct |
30 |
Correct |
262 ms |
34900 KB |
Output is correct |
31 |
Correct |
498 ms |
34648 KB |
Output is correct |
32 |
Correct |
702 ms |
34752 KB |
Output is correct |
33 |
Correct |
554 ms |
34940 KB |
Output is correct |
34 |
Correct |
563 ms |
34768 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
36 |
Correct |
346 ms |
12260 KB |
Output is correct |
37 |
Correct |
1446 ms |
34916 KB |
Output is correct |
38 |
Correct |
1478 ms |
34740 KB |
Output is correct |
39 |
Correct |
1628 ms |
33860 KB |
Output is correct |
40 |
Correct |
557 ms |
18652 KB |
Output is correct |
41 |
Correct |
192 ms |
10212 KB |
Output is correct |
42 |
Correct |
23 ms |
2668 KB |
Output is correct |
43 |
Correct |
1742 ms |
34860 KB |
Output is correct |
44 |
Correct |
1487 ms |
35056 KB |
Output is correct |
45 |
Correct |
917 ms |
34888 KB |
Output is correct |
46 |
Correct |
680 ms |
34768 KB |
Output is correct |
47 |
Correct |
542 ms |
34320 KB |
Output is correct |
48 |
Correct |
693 ms |
34768 KB |
Output is correct |
49 |
Correct |
674 ms |
34768 KB |
Output is correct |
50 |
Correct |
511 ms |
34128 KB |
Output is correct |
51 |
Correct |
8 ms |
1776 KB |
Output is correct |
52 |
Correct |
8 ms |
1776 KB |
Output is correct |
53 |
Correct |
8 ms |
1776 KB |
Output is correct |
54 |
Correct |
18 ms |
1776 KB |
Output is correct |
55 |
Correct |
19 ms |
1776 KB |
Output is correct |
56 |
Correct |
17 ms |
1776 KB |
Output is correct |
57 |
Correct |
85 ms |
12260 KB |
Output is correct |
58 |
Correct |
85 ms |
12188 KB |
Output is correct |
59 |
Correct |
87 ms |
12260 KB |
Output is correct |
60 |
Correct |
302 ms |
12268 KB |
Output is correct |
61 |
Correct |
297 ms |
12408 KB |
Output is correct |
62 |
Correct |
308 ms |
12260 KB |
Output is correct |
63 |
Correct |
837 ms |
12372 KB |
Output is correct |
64 |
Correct |
814 ms |
12260 KB |
Output is correct |
65 |
Correct |
818 ms |
12260 KB |
Output is correct |
66 |
Correct |
149 ms |
12260 KB |
Output is correct |
67 |
Correct |
157 ms |
12260 KB |
Output is correct |
68 |
Correct |
156 ms |
12260 KB |
Output is correct |
69 |
Correct |
166 ms |
12260 KB |
Output is correct |
70 |
Correct |
157 ms |
12388 KB |
Output is correct |
71 |
Correct |
157 ms |
12260 KB |
Output is correct |
72 |
Correct |
160 ms |
12260 KB |
Output is correct |
73 |
Correct |
160 ms |
12260 KB |
Output is correct |
74 |
Correct |
158 ms |
12388 KB |
Output is correct |
75 |
Correct |
273 ms |
35024 KB |
Output is correct |
76 |
Correct |
274 ms |
35284 KB |
Output is correct |
77 |
Correct |
243 ms |
35196 KB |
Output is correct |
78 |
Correct |
259 ms |
35024 KB |
Output is correct |
79 |
Correct |
533 ms |
35024 KB |
Output is correct |
80 |
Correct |
258 ms |
34896 KB |
Output is correct |
81 |
Correct |
1612 ms |
35140 KB |
Output is correct |
82 |
Correct |
1293 ms |
35280 KB |
Output is correct |
83 |
Correct |
1450 ms |
35076 KB |
Output is correct |
84 |
Correct |
1600 ms |
35132 KB |
Output is correct |
85 |
Correct |
1444 ms |
35124 KB |
Output is correct |
86 |
Correct |
1319 ms |
35160 KB |
Output is correct |
87 |
Correct |
1703 ms |
35284 KB |
Output is correct |
88 |
Correct |
2781 ms |
35152 KB |
Output is correct |
89 |
Correct |
2836 ms |
37456 KB |
Output is correct |
90 |
Correct |
2832 ms |
37456 KB |
Output is correct |
91 |
Correct |
2815 ms |
37456 KB |
Output is correct |
92 |
Correct |
2860 ms |
37456 KB |
Output is correct |
93 |
Correct |
1209 ms |
40996 KB |
Output is correct |
94 |
Correct |
1131 ms |
41552 KB |
Output is correct |
95 |
Correct |
1237 ms |
40912 KB |
Output is correct |
96 |
Correct |
1046 ms |
41040 KB |
Output is correct |
97 |
Correct |
1593 ms |
41004 KB |
Output is correct |
98 |
Correct |
784 ms |
41424 KB |
Output is correct |
99 |
Correct |
1140 ms |
41288 KB |
Output is correct |
100 |
Correct |
1008 ms |
40892 KB |
Output is correct |
101 |
Correct |
1022 ms |
41376 KB |
Output is correct |
102 |
Correct |
1104 ms |
41168 KB |
Output is correct |
103 |
Correct |
1905 ms |
41044 KB |
Output is correct |
104 |
Correct |
1092 ms |
40960 KB |
Output is correct |
105 |
Correct |
674 ms |
38864 KB |
Output is correct |
106 |
Correct |
671 ms |
41824 KB |
Output is correct |
107 |
Correct |
707 ms |
41968 KB |
Output is correct |
108 |
Correct |
707 ms |
42064 KB |
Output is correct |
109 |
Correct |
702 ms |
41904 KB |
Output is correct |
110 |
Correct |
696 ms |
42024 KB |
Output is correct |
111 |
Correct |
683 ms |
41884 KB |
Output is correct |
112 |
Correct |
700 ms |
42192 KB |
Output is correct |
113 |
Correct |
701 ms |
41936 KB |
Output is correct |
114 |
Correct |
675 ms |
41936 KB |
Output is correct |
115 |
Correct |
668 ms |
41828 KB |
Output is correct |
116 |
Correct |
672 ms |
41808 KB |
Output is correct |