#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline int in() {
bool minus = false;
int result = 0;
char ch = getchar_unlocked();
while(true) {
if(ch == '-')
break;
if(ch >= '0' && ch <= '9')
break;
ch = getchar_unlocked();
}
if(ch == '-')
minus = true;
else
result = ch-'0';
while(true) {
ch = getchar_unlocked();
if (ch < '0' || ch > '9')
break;
result = result*10 + (ch - '0');
}
return minus?-result:result;
}
inline void out(int x) {
int rev=x, c=0;
while(!(rev%10)) {
++c;
rev/=10;
}
rev=0;
while(x) {
rev=rev*10+x%10;
x/=10;
}
while(rev) {
putchar_unlocked(rev%10+'0');
rev/=10;
}
while(c--)
putchar_unlocked('0');
}
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() {
n=in();
for(int i=0; i<n; ++i) {
x[i]=in(), y[i]=in(), r[i]=in();
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) {
out(a[i]+1);
putchar_unlocked(' ');
}
}
Compilation message
circle_selection.cpp: In function 'void rs(int)':
circle_selection.cpp:57: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:83: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:83: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 |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
580 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
612 KB |
Output is correct |
9 |
Correct |
2 ms |
612 KB |
Output is correct |
10 |
Correct |
2 ms |
624 KB |
Output is correct |
11 |
Correct |
2 ms |
624 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
2 ms |
628 KB |
Output is correct |
14 |
Correct |
2 ms |
628 KB |
Output is correct |
15 |
Correct |
2 ms |
628 KB |
Output is correct |
16 |
Correct |
2 ms |
628 KB |
Output is correct |
17 |
Correct |
3 ms |
628 KB |
Output is correct |
18 |
Correct |
2 ms |
628 KB |
Output is correct |
19 |
Correct |
4 ms |
880 KB |
Output is correct |
20 |
Correct |
4 ms |
880 KB |
Output is correct |
21 |
Correct |
4 ms |
912 KB |
Output is correct |
22 |
Correct |
10 ms |
1040 KB |
Output is correct |
23 |
Correct |
8 ms |
1040 KB |
Output is correct |
24 |
Correct |
15 ms |
1056 KB |
Output is correct |
25 |
Correct |
23 ms |
1312 KB |
Output is correct |
26 |
Correct |
10 ms |
1312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
146 ms |
15320 KB |
Output is correct |
2 |
Correct |
162 ms |
15968 KB |
Output is correct |
3 |
Correct |
171 ms |
15968 KB |
Output is correct |
4 |
Correct |
133 ms |
15968 KB |
Output is correct |
5 |
Correct |
388 ms |
17748 KB |
Output is correct |
6 |
Correct |
781 ms |
25436 KB |
Output is correct |
7 |
Correct |
383 ms |
25436 KB |
Output is correct |
8 |
Correct |
560 ms |
25436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
25436 KB |
Output is correct |
2 |
Correct |
209 ms |
25436 KB |
Output is correct |
3 |
Correct |
910 ms |
25436 KB |
Output is correct |
4 |
Correct |
879 ms |
25436 KB |
Output is correct |
5 |
Correct |
702 ms |
25436 KB |
Output is correct |
6 |
Correct |
259 ms |
25436 KB |
Output is correct |
7 |
Correct |
145 ms |
25436 KB |
Output is correct |
8 |
Correct |
33 ms |
25436 KB |
Output is correct |
9 |
Correct |
796 ms |
25436 KB |
Output is correct |
10 |
Correct |
585 ms |
25436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
881 ms |
25436 KB |
Output is correct |
2 |
Execution timed out |
3033 ms |
40188 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
580 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
612 KB |
Output is correct |
9 |
Correct |
2 ms |
612 KB |
Output is correct |
10 |
Correct |
2 ms |
624 KB |
Output is correct |
11 |
Correct |
2 ms |
624 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
2 ms |
628 KB |
Output is correct |
14 |
Correct |
2 ms |
628 KB |
Output is correct |
15 |
Correct |
2 ms |
628 KB |
Output is correct |
16 |
Correct |
2 ms |
628 KB |
Output is correct |
17 |
Correct |
3 ms |
628 KB |
Output is correct |
18 |
Correct |
2 ms |
628 KB |
Output is correct |
19 |
Correct |
4 ms |
880 KB |
Output is correct |
20 |
Correct |
4 ms |
880 KB |
Output is correct |
21 |
Correct |
4 ms |
912 KB |
Output is correct |
22 |
Correct |
10 ms |
1040 KB |
Output is correct |
23 |
Correct |
8 ms |
1040 KB |
Output is correct |
24 |
Correct |
15 ms |
1056 KB |
Output is correct |
25 |
Correct |
23 ms |
1312 KB |
Output is correct |
26 |
Correct |
10 ms |
1312 KB |
Output is correct |
27 |
Correct |
6 ms |
40188 KB |
Output is correct |
28 |
Correct |
6 ms |
40188 KB |
Output is correct |
29 |
Correct |
6 ms |
40188 KB |
Output is correct |
30 |
Correct |
16 ms |
40188 KB |
Output is correct |
31 |
Correct |
23 ms |
40188 KB |
Output is correct |
32 |
Correct |
19 ms |
40188 KB |
Output is correct |
33 |
Correct |
52 ms |
40188 KB |
Output is correct |
34 |
Correct |
55 ms |
40188 KB |
Output is correct |
35 |
Correct |
63 ms |
40188 KB |
Output is correct |
36 |
Correct |
207 ms |
40188 KB |
Output is correct |
37 |
Correct |
224 ms |
40188 KB |
Output is correct |
38 |
Correct |
206 ms |
40188 KB |
Output is correct |
39 |
Correct |
271 ms |
40188 KB |
Output is correct |
40 |
Correct |
277 ms |
40188 KB |
Output is correct |
41 |
Correct |
267 ms |
40188 KB |
Output is correct |
42 |
Correct |
157 ms |
40188 KB |
Output is correct |
43 |
Correct |
304 ms |
40188 KB |
Output is correct |
44 |
Correct |
287 ms |
40188 KB |
Output is correct |
45 |
Correct |
291 ms |
40188 KB |
Output is correct |
46 |
Correct |
275 ms |
40188 KB |
Output is correct |
47 |
Correct |
249 ms |
40188 KB |
Output is correct |
48 |
Correct |
333 ms |
40188 KB |
Output is correct |
49 |
Correct |
309 ms |
40188 KB |
Output is correct |
50 |
Correct |
290 ms |
40188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
580 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
612 KB |
Output is correct |
9 |
Correct |
2 ms |
612 KB |
Output is correct |
10 |
Correct |
2 ms |
624 KB |
Output is correct |
11 |
Correct |
2 ms |
624 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
2 ms |
628 KB |
Output is correct |
14 |
Correct |
2 ms |
628 KB |
Output is correct |
15 |
Correct |
2 ms |
628 KB |
Output is correct |
16 |
Correct |
2 ms |
628 KB |
Output is correct |
17 |
Correct |
3 ms |
628 KB |
Output is correct |
18 |
Correct |
2 ms |
628 KB |
Output is correct |
19 |
Correct |
4 ms |
880 KB |
Output is correct |
20 |
Correct |
4 ms |
880 KB |
Output is correct |
21 |
Correct |
4 ms |
912 KB |
Output is correct |
22 |
Correct |
10 ms |
1040 KB |
Output is correct |
23 |
Correct |
8 ms |
1040 KB |
Output is correct |
24 |
Correct |
15 ms |
1056 KB |
Output is correct |
25 |
Correct |
23 ms |
1312 KB |
Output is correct |
26 |
Correct |
10 ms |
1312 KB |
Output is correct |
27 |
Correct |
146 ms |
15320 KB |
Output is correct |
28 |
Correct |
162 ms |
15968 KB |
Output is correct |
29 |
Correct |
171 ms |
15968 KB |
Output is correct |
30 |
Correct |
133 ms |
15968 KB |
Output is correct |
31 |
Correct |
388 ms |
17748 KB |
Output is correct |
32 |
Correct |
781 ms |
25436 KB |
Output is correct |
33 |
Correct |
383 ms |
25436 KB |
Output is correct |
34 |
Correct |
560 ms |
25436 KB |
Output is correct |
35 |
Correct |
3 ms |
25436 KB |
Output is correct |
36 |
Correct |
209 ms |
25436 KB |
Output is correct |
37 |
Correct |
910 ms |
25436 KB |
Output is correct |
38 |
Correct |
879 ms |
25436 KB |
Output is correct |
39 |
Correct |
702 ms |
25436 KB |
Output is correct |
40 |
Correct |
259 ms |
25436 KB |
Output is correct |
41 |
Correct |
145 ms |
25436 KB |
Output is correct |
42 |
Correct |
33 ms |
25436 KB |
Output is correct |
43 |
Correct |
796 ms |
25436 KB |
Output is correct |
44 |
Correct |
585 ms |
25436 KB |
Output is correct |
45 |
Correct |
881 ms |
25436 KB |
Output is correct |
46 |
Execution timed out |
3033 ms |
40188 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |