#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=3e5;
int n, p[mxN], p2[mxN], a[mxN];
ll x[mxN], y[mxN], r[mxN];
unordered_map<int, vector<array<int, 2>>> mp;
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({y[p2[i]]>>k, 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];
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, 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) {
auto mf=mp.find(b);
if(mf==mp.end())
continue;
vector<array<int, 2>> &v=mf->second;
for(int j=lower_bound(v.begin(), v.end(), array<int, 2>{(y[p[i]]>>k)-2, 0})-v.begin(); j<v.size()&&v[j][0]<=(y[p[i]]>>k)+2; ++j) {
ll dx=x[p[i]]-x[v[j][1]], dy=y[p[i]]-y[v[j][1]], rs=r[p[i]]+r[v[j][1]];
if(dx*dx+dy*dy<=rs*rs&&a[v[j][1]]==-1)
a[v[j][1]]=p[i];
}
}
}
}
for(int i=0; i<n; ++i)
cout << a[i]+1 << " ";
}
Compilation message
circle_selection.cpp: In function 'void rs(int)':
circle_selection.cpp:15:39: warning: narrowing conversion of '(y[p2[i]] >> k)' from 'long long int' to 'int' inside { } [-Wnarrowing]
mp[x[p2[i]]>>k].push_back({y[p2[i]]>>k, p2[i]});
~~~~~~~~^~~
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:44:73: warning: narrowing conversion of '((y[p[i]] >> k) - 2)' from 'long long int' to 'int' inside { } [-Wnarrowing]
for(int j=lower_bound(v.begin(), v.end(), array<int, 2>{(y[p[i]]>>k)-2, 0})-v.begin(); j<v.size()&&v[j][0]<=(y[p[i]]>>k)+2; ++j) {
~~~~~~~~~~~~^~
circle_selection.cpp:44:93: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=lower_bound(v.begin(), v.end(), array<int, 2>{(y[p[i]]>>k)-2, 0})-v.begin(); j<v.size()&&v[j][0]<=(y[p[i]]>>k)+2; ++j) {
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
576 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
576 KB |
Output is correct |
7 |
Correct |
2 ms |
576 KB |
Output is correct |
8 |
Correct |
2 ms |
576 KB |
Output is correct |
9 |
Correct |
2 ms |
576 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
576 KB |
Output is correct |
12 |
Correct |
2 ms |
576 KB |
Output is correct |
13 |
Correct |
2 ms |
576 KB |
Output is correct |
14 |
Correct |
2 ms |
576 KB |
Output is correct |
15 |
Correct |
2 ms |
576 KB |
Output is correct |
16 |
Correct |
4 ms |
576 KB |
Output is correct |
17 |
Correct |
3 ms |
576 KB |
Output is correct |
18 |
Correct |
3 ms |
576 KB |
Output is correct |
19 |
Correct |
6 ms |
816 KB |
Output is correct |
20 |
Correct |
30 ms |
816 KB |
Output is correct |
21 |
Correct |
6 ms |
832 KB |
Output is correct |
22 |
Correct |
13 ms |
1088 KB |
Output is correct |
23 |
Correct |
10 ms |
1088 KB |
Output is correct |
24 |
Correct |
13 ms |
1120 KB |
Output is correct |
25 |
Correct |
15 ms |
1264 KB |
Output is correct |
26 |
Correct |
12 ms |
1264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
232 ms |
15328 KB |
Output is correct |
2 |
Correct |
258 ms |
15932 KB |
Output is correct |
3 |
Correct |
263 ms |
15932 KB |
Output is correct |
4 |
Correct |
218 ms |
15932 KB |
Output is correct |
5 |
Correct |
442 ms |
17868 KB |
Output is correct |
6 |
Correct |
783 ms |
25500 KB |
Output is correct |
7 |
Correct |
459 ms |
25500 KB |
Output is correct |
8 |
Correct |
520 ms |
25500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
25500 KB |
Output is correct |
2 |
Correct |
229 ms |
25500 KB |
Output is correct |
3 |
Correct |
935 ms |
25500 KB |
Output is correct |
4 |
Correct |
919 ms |
25500 KB |
Output is correct |
5 |
Correct |
734 ms |
25500 KB |
Output is correct |
6 |
Correct |
328 ms |
25500 KB |
Output is correct |
7 |
Correct |
160 ms |
25500 KB |
Output is correct |
8 |
Correct |
45 ms |
25500 KB |
Output is correct |
9 |
Correct |
869 ms |
25500 KB |
Output is correct |
10 |
Correct |
659 ms |
25500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
960 ms |
25500 KB |
Output is correct |
2 |
Correct |
2956 ms |
40544 KB |
Output is correct |
3 |
Correct |
413 ms |
40544 KB |
Output is correct |
4 |
Correct |
1876 ms |
40544 KB |
Output is correct |
5 |
Correct |
2332 ms |
40544 KB |
Output is correct |
6 |
Correct |
391 ms |
40544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
576 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
576 KB |
Output is correct |
7 |
Correct |
2 ms |
576 KB |
Output is correct |
8 |
Correct |
2 ms |
576 KB |
Output is correct |
9 |
Correct |
2 ms |
576 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
576 KB |
Output is correct |
12 |
Correct |
2 ms |
576 KB |
Output is correct |
13 |
Correct |
2 ms |
576 KB |
Output is correct |
14 |
Correct |
2 ms |
576 KB |
Output is correct |
15 |
Correct |
2 ms |
576 KB |
Output is correct |
16 |
Correct |
4 ms |
576 KB |
Output is correct |
17 |
Correct |
3 ms |
576 KB |
Output is correct |
18 |
Correct |
3 ms |
576 KB |
Output is correct |
19 |
Correct |
6 ms |
816 KB |
Output is correct |
20 |
Correct |
30 ms |
816 KB |
Output is correct |
21 |
Correct |
6 ms |
832 KB |
Output is correct |
22 |
Correct |
13 ms |
1088 KB |
Output is correct |
23 |
Correct |
10 ms |
1088 KB |
Output is correct |
24 |
Correct |
13 ms |
1120 KB |
Output is correct |
25 |
Correct |
15 ms |
1264 KB |
Output is correct |
26 |
Correct |
12 ms |
1264 KB |
Output is correct |
27 |
Correct |
11 ms |
40544 KB |
Output is correct |
28 |
Correct |
11 ms |
40544 KB |
Output is correct |
29 |
Correct |
10 ms |
40544 KB |
Output is correct |
30 |
Correct |
21 ms |
40544 KB |
Output is correct |
31 |
Correct |
23 ms |
40544 KB |
Output is correct |
32 |
Correct |
23 ms |
40544 KB |
Output is correct |
33 |
Correct |
89 ms |
40544 KB |
Output is correct |
34 |
Correct |
91 ms |
40544 KB |
Output is correct |
35 |
Correct |
98 ms |
40544 KB |
Output is correct |
36 |
Correct |
277 ms |
40544 KB |
Output is correct |
37 |
Correct |
272 ms |
40544 KB |
Output is correct |
38 |
Correct |
252 ms |
40544 KB |
Output is correct |
39 |
Correct |
318 ms |
40544 KB |
Output is correct |
40 |
Correct |
317 ms |
40544 KB |
Output is correct |
41 |
Correct |
322 ms |
40544 KB |
Output is correct |
42 |
Correct |
193 ms |
40544 KB |
Output is correct |
43 |
Correct |
373 ms |
40544 KB |
Output is correct |
44 |
Correct |
357 ms |
40544 KB |
Output is correct |
45 |
Correct |
394 ms |
40544 KB |
Output is correct |
46 |
Correct |
343 ms |
40544 KB |
Output is correct |
47 |
Correct |
292 ms |
40544 KB |
Output is correct |
48 |
Correct |
327 ms |
40544 KB |
Output is correct |
49 |
Correct |
346 ms |
40544 KB |
Output is correct |
50 |
Correct |
378 ms |
40544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
576 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
576 KB |
Output is correct |
7 |
Correct |
2 ms |
576 KB |
Output is correct |
8 |
Correct |
2 ms |
576 KB |
Output is correct |
9 |
Correct |
2 ms |
576 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
576 KB |
Output is correct |
12 |
Correct |
2 ms |
576 KB |
Output is correct |
13 |
Correct |
2 ms |
576 KB |
Output is correct |
14 |
Correct |
2 ms |
576 KB |
Output is correct |
15 |
Correct |
2 ms |
576 KB |
Output is correct |
16 |
Correct |
4 ms |
576 KB |
Output is correct |
17 |
Correct |
3 ms |
576 KB |
Output is correct |
18 |
Correct |
3 ms |
576 KB |
Output is correct |
19 |
Correct |
6 ms |
816 KB |
Output is correct |
20 |
Correct |
30 ms |
816 KB |
Output is correct |
21 |
Correct |
6 ms |
832 KB |
Output is correct |
22 |
Correct |
13 ms |
1088 KB |
Output is correct |
23 |
Correct |
10 ms |
1088 KB |
Output is correct |
24 |
Correct |
13 ms |
1120 KB |
Output is correct |
25 |
Correct |
15 ms |
1264 KB |
Output is correct |
26 |
Correct |
12 ms |
1264 KB |
Output is correct |
27 |
Correct |
232 ms |
15328 KB |
Output is correct |
28 |
Correct |
258 ms |
15932 KB |
Output is correct |
29 |
Correct |
263 ms |
15932 KB |
Output is correct |
30 |
Correct |
218 ms |
15932 KB |
Output is correct |
31 |
Correct |
442 ms |
17868 KB |
Output is correct |
32 |
Correct |
783 ms |
25500 KB |
Output is correct |
33 |
Correct |
459 ms |
25500 KB |
Output is correct |
34 |
Correct |
520 ms |
25500 KB |
Output is correct |
35 |
Correct |
2 ms |
25500 KB |
Output is correct |
36 |
Correct |
229 ms |
25500 KB |
Output is correct |
37 |
Correct |
935 ms |
25500 KB |
Output is correct |
38 |
Correct |
919 ms |
25500 KB |
Output is correct |
39 |
Correct |
734 ms |
25500 KB |
Output is correct |
40 |
Correct |
328 ms |
25500 KB |
Output is correct |
41 |
Correct |
160 ms |
25500 KB |
Output is correct |
42 |
Correct |
45 ms |
25500 KB |
Output is correct |
43 |
Correct |
869 ms |
25500 KB |
Output is correct |
44 |
Correct |
659 ms |
25500 KB |
Output is correct |
45 |
Correct |
960 ms |
25500 KB |
Output is correct |
46 |
Correct |
2956 ms |
40544 KB |
Output is correct |
47 |
Correct |
413 ms |
40544 KB |
Output is correct |
48 |
Correct |
1876 ms |
40544 KB |
Output is correct |
49 |
Correct |
2332 ms |
40544 KB |
Output is correct |
50 |
Correct |
391 ms |
40544 KB |
Output is correct |
51 |
Correct |
11 ms |
40544 KB |
Output is correct |
52 |
Correct |
11 ms |
40544 KB |
Output is correct |
53 |
Correct |
10 ms |
40544 KB |
Output is correct |
54 |
Correct |
21 ms |
40544 KB |
Output is correct |
55 |
Correct |
23 ms |
40544 KB |
Output is correct |
56 |
Correct |
23 ms |
40544 KB |
Output is correct |
57 |
Correct |
89 ms |
40544 KB |
Output is correct |
58 |
Correct |
91 ms |
40544 KB |
Output is correct |
59 |
Correct |
98 ms |
40544 KB |
Output is correct |
60 |
Correct |
277 ms |
40544 KB |
Output is correct |
61 |
Correct |
272 ms |
40544 KB |
Output is correct |
62 |
Correct |
252 ms |
40544 KB |
Output is correct |
63 |
Correct |
318 ms |
40544 KB |
Output is correct |
64 |
Correct |
317 ms |
40544 KB |
Output is correct |
65 |
Correct |
322 ms |
40544 KB |
Output is correct |
66 |
Correct |
193 ms |
40544 KB |
Output is correct |
67 |
Correct |
373 ms |
40544 KB |
Output is correct |
68 |
Correct |
357 ms |
40544 KB |
Output is correct |
69 |
Correct |
394 ms |
40544 KB |
Output is correct |
70 |
Correct |
343 ms |
40544 KB |
Output is correct |
71 |
Correct |
292 ms |
40544 KB |
Output is correct |
72 |
Correct |
327 ms |
40544 KB |
Output is correct |
73 |
Correct |
346 ms |
40544 KB |
Output is correct |
74 |
Correct |
378 ms |
40544 KB |
Output is correct |
75 |
Correct |
304 ms |
40544 KB |
Output is correct |
76 |
Correct |
343 ms |
40544 KB |
Output is correct |
77 |
Correct |
319 ms |
40544 KB |
Output is correct |
78 |
Correct |
276 ms |
40544 KB |
Output is correct |
79 |
Correct |
415 ms |
40544 KB |
Output is correct |
80 |
Correct |
316 ms |
40544 KB |
Output is correct |
81 |
Correct |
1221 ms |
40544 KB |
Output is correct |
82 |
Correct |
1344 ms |
40544 KB |
Output is correct |
83 |
Correct |
1195 ms |
40544 KB |
Output is correct |
84 |
Correct |
860 ms |
40544 KB |
Output is correct |
85 |
Correct |
1167 ms |
40544 KB |
Output is correct |
86 |
Correct |
1242 ms |
40544 KB |
Output is correct |
87 |
Correct |
864 ms |
40544 KB |
Output is correct |
88 |
Correct |
1184 ms |
40544 KB |
Output is correct |
89 |
Correct |
1211 ms |
40544 KB |
Output is correct |
90 |
Correct |
1231 ms |
40544 KB |
Output is correct |
91 |
Correct |
1137 ms |
40544 KB |
Output is correct |
92 |
Correct |
1168 ms |
40544 KB |
Output is correct |
93 |
Correct |
2826 ms |
40544 KB |
Output is correct |
94 |
Correct |
960 ms |
40544 KB |
Output is correct |
95 |
Correct |
2872 ms |
40544 KB |
Output is correct |
96 |
Correct |
2367 ms |
40544 KB |
Output is correct |
97 |
Correct |
1016 ms |
40544 KB |
Output is correct |
98 |
Correct |
1072 ms |
40544 KB |
Output is correct |
99 |
Correct |
2859 ms |
40544 KB |
Output is correct |
100 |
Execution timed out |
3057 ms |
40544 KB |
Time limit exceeded |
101 |
Halted |
0 ms |
0 KB |
- |