#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define pb emplace_back
#define F first
#define S second
#define IOS cin.tie(0),ios_base::sync_with_stdio(false)
#define f2(x) ((x)*(x))
const int maxn=3e5+3,inf=1ll<<60,bl=2e9+3;
struct C{int x,y,r,id;}a[maxn];
int n,res[maxn];
bitset<maxn>rmv;
unordered_map<int,VI>mp;
main(){
IOS;
cin>>n;
REP(i,0,n)cin>>a[i].x>>a[i].y>>a[i].r,a[i].id=i;
sort(a,a+n,[](C x,C y){return x.r==y.r?x.id<y.id:x.r>y.r;});
int k=1ll<<31;
REP(i,0,n){
if(rmv[i])continue;
while(a[i].r<(k>>1)){
k>>=1;
mp.clear();
REP(j,i,n)if(!rmv[j])mp[a[j].x/k*bl+a[j].y/k].pb(j);
}
int xx=a[i].x/k,yy=a[i].y/k;
REP(x,xx-2,xx+3)REP(y,yy-2,yy+3){
auto&tls=mp[x*bl+y];
for(auto it=tls.begin();it!=tls.end();++it){
if(!rmv[*it]&&f2(a[i].x-a[*it].x)+f2(a[i].y-a[*it].y)<=f2(a[i].r+a[*it].r)){
res[a[*it].id]=a[i].id;
rmv[*it]=1;
}
}
}
}
REP(i,0,n)cout<<res[i]+1<<" ";
}
Compilation message
circle_selection.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
44 ms |
4524 KB |
Output is correct |
23 |
Correct |
53 ms |
4520 KB |
Output is correct |
24 |
Correct |
34 ms |
3240 KB |
Output is correct |
25 |
Correct |
55 ms |
3624 KB |
Output is correct |
26 |
Correct |
44 ms |
4392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
229 ms |
18620 KB |
Output is correct |
2 |
Correct |
277 ms |
18572 KB |
Output is correct |
3 |
Correct |
270 ms |
17924 KB |
Output is correct |
4 |
Correct |
202 ms |
14692 KB |
Output is correct |
5 |
Correct |
674 ms |
19092 KB |
Output is correct |
6 |
Correct |
2211 ms |
55216 KB |
Output is correct |
7 |
Correct |
684 ms |
20548 KB |
Output is correct |
8 |
Correct |
971 ms |
27924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1866 ms |
71288 KB |
Output is correct |
3 |
Execution timed out |
3028 ms |
151412 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3040 ms |
83448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
44 ms |
4524 KB |
Output is correct |
23 |
Correct |
53 ms |
4520 KB |
Output is correct |
24 |
Correct |
34 ms |
3240 KB |
Output is correct |
25 |
Correct |
55 ms |
3624 KB |
Output is correct |
26 |
Correct |
44 ms |
4392 KB |
Output is correct |
27 |
Correct |
8 ms |
992 KB |
Output is correct |
28 |
Correct |
9 ms |
1116 KB |
Output is correct |
29 |
Correct |
10 ms |
1068 KB |
Output is correct |
30 |
Correct |
104 ms |
8736 KB |
Output is correct |
31 |
Correct |
117 ms |
8840 KB |
Output is correct |
32 |
Correct |
90 ms |
6192 KB |
Output is correct |
33 |
Correct |
62 ms |
5792 KB |
Output is correct |
34 |
Correct |
74 ms |
5864 KB |
Output is correct |
35 |
Correct |
78 ms |
6324 KB |
Output is correct |
36 |
Correct |
2153 ms |
75944 KB |
Output is correct |
37 |
Correct |
2016 ms |
71192 KB |
Output is correct |
38 |
Correct |
2120 ms |
76556 KB |
Output is correct |
39 |
Correct |
536 ms |
11464 KB |
Output is correct |
40 |
Correct |
590 ms |
11636 KB |
Output is correct |
41 |
Correct |
593 ms |
11548 KB |
Output is correct |
42 |
Correct |
429 ms |
10668 KB |
Output is correct |
43 |
Correct |
2167 ms |
139304 KB |
Output is correct |
44 |
Correct |
1981 ms |
139444 KB |
Output is correct |
45 |
Correct |
2244 ms |
139304 KB |
Output is correct |
46 |
Correct |
2100 ms |
139224 KB |
Output is correct |
47 |
Correct |
1941 ms |
139656 KB |
Output is correct |
48 |
Correct |
1985 ms |
139480 KB |
Output is correct |
49 |
Correct |
2888 ms |
139416 KB |
Output is correct |
50 |
Correct |
2305 ms |
139264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
44 ms |
4524 KB |
Output is correct |
23 |
Correct |
53 ms |
4520 KB |
Output is correct |
24 |
Correct |
34 ms |
3240 KB |
Output is correct |
25 |
Correct |
55 ms |
3624 KB |
Output is correct |
26 |
Correct |
44 ms |
4392 KB |
Output is correct |
27 |
Correct |
229 ms |
18620 KB |
Output is correct |
28 |
Correct |
277 ms |
18572 KB |
Output is correct |
29 |
Correct |
270 ms |
17924 KB |
Output is correct |
30 |
Correct |
202 ms |
14692 KB |
Output is correct |
31 |
Correct |
674 ms |
19092 KB |
Output is correct |
32 |
Correct |
2211 ms |
55216 KB |
Output is correct |
33 |
Correct |
684 ms |
20548 KB |
Output is correct |
34 |
Correct |
971 ms |
27924 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
1866 ms |
71288 KB |
Output is correct |
37 |
Execution timed out |
3028 ms |
151412 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |