#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=3e5;
int n, p[mxN], p2[mxN], a[mxN], k=30;
ll x[mxN], y[mxN], r[mxN];
unordered_map<int, vector<int>> mp;
struct cmp1 {
__attribute__((always_inline)) bool operator()(const int &a, const int &b) {
return y[a]>>k<b;
}
};
void rs(int k) {
mp.clear();
for(int i=0; i<n; ++i)
if(a[p2[i]]==-1)
mp[x[p2[i]]>>k].push_back(p2[i]);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=0; i<n; ++i) {
cin >> x[i] >> y[i] >> r[i], swap(x[i], y[i]);
p[i]=p2[i]=i;
}
sort(p, p+n, [&](const int &a, const int &b) {
return r[a]==r[b]?a<b:r[a]>r[b];
});
sort(p2, p2+n, [&](const int &a, const int &b) {
return y[a]<y[b];
});
memset(a, -1, 4*n);
for(int i=-1; i+1<n; --i, --k) {
rs(k);
while(++i<n&&r[p[i]]>=1<<(k-1)) {
if(a[p[i]]!=-1)
continue;
for(ll b=(x[p[i]]>>k)-2; b<=(x[p[i]]>>k)+2; ++b) {
auto mf=mp.find(b);
if(mf==mp.end())
continue;
vector<int> &v=mf->second;
for(int j=lower_bound(v.begin(), v.end(), (y[p[i]]>>k)-2, cmp1())-v.begin(); j<v.size()&&y[v[j]]>>k<=(y[p[i]]>>k)+2; ++j) {
ll dx=x[p[i]]-x[v[j]], dy=y[p[i]]-y[v[j]], rs=r[p[i]]+r[v[j]];
if(dx*dx+dy*dy<=rs*rs&&a[v[j]]==-1)
a[v[j]]=p[i];
}
}
}
}
for(int i=0; i<n; ++i)
cout << a[i]+1 << " ";
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:50:83: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=lower_bound(v.begin(), v.end(), (y[p[i]]>>k)-2, cmp1())-v.begin(); j<v.size()&&y[v[j]]>>k<=(y[p[i]]>>k)+2; ++j) {
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
592 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
2 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
2 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
7 ms |
892 KB |
Output is correct |
20 |
Correct |
5 ms |
892 KB |
Output is correct |
21 |
Correct |
6 ms |
908 KB |
Output is correct |
22 |
Correct |
13 ms |
1308 KB |
Output is correct |
23 |
Correct |
19 ms |
1332 KB |
Output is correct |
24 |
Correct |
19 ms |
1332 KB |
Output is correct |
25 |
Correct |
14 ms |
1340 KB |
Output is correct |
26 |
Correct |
16 ms |
1344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
270 ms |
14472 KB |
Output is correct |
2 |
Correct |
287 ms |
14568 KB |
Output is correct |
3 |
Correct |
280 ms |
14568 KB |
Output is correct |
4 |
Correct |
297 ms |
14568 KB |
Output is correct |
5 |
Correct |
456 ms |
14568 KB |
Output is correct |
6 |
Correct |
525 ms |
14596 KB |
Output is correct |
7 |
Correct |
474 ms |
14596 KB |
Output is correct |
8 |
Correct |
488 ms |
14596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14596 KB |
Output is correct |
2 |
Correct |
225 ms |
14596 KB |
Output is correct |
3 |
Correct |
875 ms |
17608 KB |
Output is correct |
4 |
Correct |
824 ms |
17672 KB |
Output is correct |
5 |
Correct |
691 ms |
17672 KB |
Output is correct |
6 |
Correct |
306 ms |
17672 KB |
Output is correct |
7 |
Correct |
158 ms |
17672 KB |
Output is correct |
8 |
Correct |
37 ms |
17672 KB |
Output is correct |
9 |
Correct |
772 ms |
17672 KB |
Output is correct |
10 |
Correct |
611 ms |
17672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
788 ms |
20956 KB |
Output is correct |
2 |
Execution timed out |
3033 ms |
40276 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
592 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
2 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
2 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
7 ms |
892 KB |
Output is correct |
20 |
Correct |
5 ms |
892 KB |
Output is correct |
21 |
Correct |
6 ms |
908 KB |
Output is correct |
22 |
Correct |
13 ms |
1308 KB |
Output is correct |
23 |
Correct |
19 ms |
1332 KB |
Output is correct |
24 |
Correct |
19 ms |
1332 KB |
Output is correct |
25 |
Correct |
14 ms |
1340 KB |
Output is correct |
26 |
Correct |
16 ms |
1344 KB |
Output is correct |
27 |
Correct |
11 ms |
40276 KB |
Output is correct |
28 |
Correct |
10 ms |
40276 KB |
Output is correct |
29 |
Correct |
10 ms |
40276 KB |
Output is correct |
30 |
Correct |
27 ms |
40276 KB |
Output is correct |
31 |
Correct |
23 ms |
40276 KB |
Output is correct |
32 |
Correct |
26 ms |
40276 KB |
Output is correct |
33 |
Correct |
88 ms |
40276 KB |
Output is correct |
34 |
Correct |
89 ms |
40276 KB |
Output is correct |
35 |
Correct |
126 ms |
40276 KB |
Output is correct |
36 |
Correct |
242 ms |
40276 KB |
Output is correct |
37 |
Correct |
273 ms |
40276 KB |
Output is correct |
38 |
Correct |
235 ms |
40276 KB |
Output is correct |
39 |
Correct |
427 ms |
40276 KB |
Output is correct |
40 |
Correct |
300 ms |
40276 KB |
Output is correct |
41 |
Correct |
295 ms |
40276 KB |
Output is correct |
42 |
Correct |
168 ms |
40276 KB |
Output is correct |
43 |
Correct |
395 ms |
40276 KB |
Output is correct |
44 |
Correct |
309 ms |
40276 KB |
Output is correct |
45 |
Correct |
313 ms |
40276 KB |
Output is correct |
46 |
Correct |
289 ms |
40276 KB |
Output is correct |
47 |
Correct |
299 ms |
40276 KB |
Output is correct |
48 |
Correct |
301 ms |
40276 KB |
Output is correct |
49 |
Correct |
337 ms |
40276 KB |
Output is correct |
50 |
Correct |
305 ms |
40276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
592 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
2 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
2 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
7 ms |
892 KB |
Output is correct |
20 |
Correct |
5 ms |
892 KB |
Output is correct |
21 |
Correct |
6 ms |
908 KB |
Output is correct |
22 |
Correct |
13 ms |
1308 KB |
Output is correct |
23 |
Correct |
19 ms |
1332 KB |
Output is correct |
24 |
Correct |
19 ms |
1332 KB |
Output is correct |
25 |
Correct |
14 ms |
1340 KB |
Output is correct |
26 |
Correct |
16 ms |
1344 KB |
Output is correct |
27 |
Correct |
270 ms |
14472 KB |
Output is correct |
28 |
Correct |
287 ms |
14568 KB |
Output is correct |
29 |
Correct |
280 ms |
14568 KB |
Output is correct |
30 |
Correct |
297 ms |
14568 KB |
Output is correct |
31 |
Correct |
456 ms |
14568 KB |
Output is correct |
32 |
Correct |
525 ms |
14596 KB |
Output is correct |
33 |
Correct |
474 ms |
14596 KB |
Output is correct |
34 |
Correct |
488 ms |
14596 KB |
Output is correct |
35 |
Correct |
3 ms |
14596 KB |
Output is correct |
36 |
Correct |
225 ms |
14596 KB |
Output is correct |
37 |
Correct |
875 ms |
17608 KB |
Output is correct |
38 |
Correct |
824 ms |
17672 KB |
Output is correct |
39 |
Correct |
691 ms |
17672 KB |
Output is correct |
40 |
Correct |
306 ms |
17672 KB |
Output is correct |
41 |
Correct |
158 ms |
17672 KB |
Output is correct |
42 |
Correct |
37 ms |
17672 KB |
Output is correct |
43 |
Correct |
772 ms |
17672 KB |
Output is correct |
44 |
Correct |
611 ms |
17672 KB |
Output is correct |
45 |
Correct |
788 ms |
20956 KB |
Output is correct |
46 |
Execution timed out |
3033 ms |
40276 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |