#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=3e5;
int n, p[mxN], a[mxN];
ll x[mxN], y[mxN], r[mxN];
unordered_map<ll, vector<int>> mp;
void rs(int k) {
mp.clear();
for(int i=0; i<n; ++i)
if(a[i]==-1)
mp[x[i]>>k<<32|y[i]>>k].push_back(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];
p[i]=i;
}
sort(p, p+n, [&](const int &a, const int &b) {
return r[a]==r[b]?a<b:r[a]>r[b];
});
memset(a, -1, 4*n);
for(int i=-1, k=30; 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) {
for(ll c=(y[p[i]]>>k)-2; c<=(y[p[i]]>>k)+2; ++c) {
auto mf=mp.find(b<<32|c);
if(mf==mp.end())
continue;
int ns=0;
vector<int> &v=mf->second;
for(int j=0; j<v.size(); ++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]]=p[i];
else
v[ns++]=v[j];
}
v.resize(ns);
}
}
}
}
for(int i=0; i<n; ++i)
cout << a[i]+1 << " ";
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<v.size(); ++j) {
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
2 ms |
564 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
692 KB |
Output is correct |
12 |
Correct |
2 ms |
692 KB |
Output is correct |
13 |
Correct |
2 ms |
692 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
3 ms |
692 KB |
Output is correct |
18 |
Correct |
3 ms |
692 KB |
Output is correct |
19 |
Correct |
5 ms |
772 KB |
Output is correct |
20 |
Correct |
5 ms |
772 KB |
Output is correct |
21 |
Correct |
5 ms |
852 KB |
Output is correct |
22 |
Correct |
18 ms |
1252 KB |
Output is correct |
23 |
Correct |
18 ms |
1268 KB |
Output is correct |
24 |
Correct |
15 ms |
1268 KB |
Output is correct |
25 |
Correct |
21 ms |
1268 KB |
Output is correct |
26 |
Correct |
19 ms |
1268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
216 ms |
12128 KB |
Output is correct |
2 |
Correct |
235 ms |
12652 KB |
Output is correct |
3 |
Correct |
243 ms |
12652 KB |
Output is correct |
4 |
Correct |
229 ms |
12652 KB |
Output is correct |
5 |
Correct |
383 ms |
14864 KB |
Output is correct |
6 |
Correct |
795 ms |
23256 KB |
Output is correct |
7 |
Correct |
400 ms |
23256 KB |
Output is correct |
8 |
Correct |
481 ms |
23256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
23256 KB |
Output is correct |
2 |
Correct |
478 ms |
23256 KB |
Output is correct |
3 |
Correct |
1918 ms |
26964 KB |
Output is correct |
4 |
Correct |
1900 ms |
33144 KB |
Output is correct |
5 |
Correct |
1728 ms |
40492 KB |
Output is correct |
6 |
Correct |
587 ms |
40492 KB |
Output is correct |
7 |
Correct |
242 ms |
40492 KB |
Output is correct |
8 |
Correct |
49 ms |
40492 KB |
Output is correct |
9 |
Correct |
1889 ms |
57132 KB |
Output is correct |
10 |
Correct |
1836 ms |
63980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1026 ms |
63980 KB |
Output is correct |
2 |
Execution timed out |
3053 ms |
76848 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
2 ms |
564 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
692 KB |
Output is correct |
12 |
Correct |
2 ms |
692 KB |
Output is correct |
13 |
Correct |
2 ms |
692 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
3 ms |
692 KB |
Output is correct |
18 |
Correct |
3 ms |
692 KB |
Output is correct |
19 |
Correct |
5 ms |
772 KB |
Output is correct |
20 |
Correct |
5 ms |
772 KB |
Output is correct |
21 |
Correct |
5 ms |
852 KB |
Output is correct |
22 |
Correct |
18 ms |
1252 KB |
Output is correct |
23 |
Correct |
18 ms |
1268 KB |
Output is correct |
24 |
Correct |
15 ms |
1268 KB |
Output is correct |
25 |
Correct |
21 ms |
1268 KB |
Output is correct |
26 |
Correct |
19 ms |
1268 KB |
Output is correct |
27 |
Correct |
10 ms |
76848 KB |
Output is correct |
28 |
Correct |
9 ms |
76848 KB |
Output is correct |
29 |
Correct |
11 ms |
76848 KB |
Output is correct |
30 |
Correct |
32 ms |
76848 KB |
Output is correct |
31 |
Correct |
41 ms |
76848 KB |
Output is correct |
32 |
Correct |
29 ms |
76848 KB |
Output is correct |
33 |
Correct |
75 ms |
76848 KB |
Output is correct |
34 |
Correct |
79 ms |
76848 KB |
Output is correct |
35 |
Correct |
82 ms |
76848 KB |
Output is correct |
36 |
Correct |
562 ms |
76848 KB |
Output is correct |
37 |
Correct |
326 ms |
76848 KB |
Output is correct |
38 |
Correct |
299 ms |
76848 KB |
Output is correct |
39 |
Correct |
698 ms |
76848 KB |
Output is correct |
40 |
Correct |
685 ms |
76848 KB |
Output is correct |
41 |
Correct |
672 ms |
76848 KB |
Output is correct |
42 |
Correct |
196 ms |
76848 KB |
Output is correct |
43 |
Correct |
469 ms |
76848 KB |
Output is correct |
44 |
Correct |
465 ms |
76848 KB |
Output is correct |
45 |
Correct |
474 ms |
76848 KB |
Output is correct |
46 |
Correct |
461 ms |
76848 KB |
Output is correct |
47 |
Correct |
480 ms |
76848 KB |
Output is correct |
48 |
Correct |
472 ms |
76848 KB |
Output is correct |
49 |
Correct |
498 ms |
76848 KB |
Output is correct |
50 |
Correct |
507 ms |
76848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
2 ms |
564 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
9 |
Correct |
2 ms |
692 KB |
Output is correct |
10 |
Correct |
2 ms |
692 KB |
Output is correct |
11 |
Correct |
2 ms |
692 KB |
Output is correct |
12 |
Correct |
2 ms |
692 KB |
Output is correct |
13 |
Correct |
2 ms |
692 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
3 ms |
692 KB |
Output is correct |
18 |
Correct |
3 ms |
692 KB |
Output is correct |
19 |
Correct |
5 ms |
772 KB |
Output is correct |
20 |
Correct |
5 ms |
772 KB |
Output is correct |
21 |
Correct |
5 ms |
852 KB |
Output is correct |
22 |
Correct |
18 ms |
1252 KB |
Output is correct |
23 |
Correct |
18 ms |
1268 KB |
Output is correct |
24 |
Correct |
15 ms |
1268 KB |
Output is correct |
25 |
Correct |
21 ms |
1268 KB |
Output is correct |
26 |
Correct |
19 ms |
1268 KB |
Output is correct |
27 |
Correct |
216 ms |
12128 KB |
Output is correct |
28 |
Correct |
235 ms |
12652 KB |
Output is correct |
29 |
Correct |
243 ms |
12652 KB |
Output is correct |
30 |
Correct |
229 ms |
12652 KB |
Output is correct |
31 |
Correct |
383 ms |
14864 KB |
Output is correct |
32 |
Correct |
795 ms |
23256 KB |
Output is correct |
33 |
Correct |
400 ms |
23256 KB |
Output is correct |
34 |
Correct |
481 ms |
23256 KB |
Output is correct |
35 |
Correct |
2 ms |
23256 KB |
Output is correct |
36 |
Correct |
478 ms |
23256 KB |
Output is correct |
37 |
Correct |
1918 ms |
26964 KB |
Output is correct |
38 |
Correct |
1900 ms |
33144 KB |
Output is correct |
39 |
Correct |
1728 ms |
40492 KB |
Output is correct |
40 |
Correct |
587 ms |
40492 KB |
Output is correct |
41 |
Correct |
242 ms |
40492 KB |
Output is correct |
42 |
Correct |
49 ms |
40492 KB |
Output is correct |
43 |
Correct |
1889 ms |
57132 KB |
Output is correct |
44 |
Correct |
1836 ms |
63980 KB |
Output is correct |
45 |
Correct |
1026 ms |
63980 KB |
Output is correct |
46 |
Execution timed out |
3053 ms |
76848 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |