#include<bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define pb push_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,vector<int>>mp;
main(){
IOS;
cin>>n;
int mnx=inf,mny=inf;
REP(i,0,n)cin>>a[i].x>>a[i].y>>a[i].r,a[i].id=i,mnx=min(mnx,a[i].x),mny=min(mny,a[i].y);
REP(i,0,n)a[i].x=a[i].x-mnx+1,a[i].y=a[i].y-mny+1;
stable_sort(a,a+n,[](const C&x,const C&y){return x.r>y.r;});
int k=inf;
REP(i,0,n){
if(rmv[i])continue;
if(2*a[i].r<k){
k=a[i].r;
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:18: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 |
3 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 |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
640 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 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 |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
816 KB |
Output is correct |
20 |
Correct |
7 ms |
688 KB |
Output is correct |
21 |
Correct |
7 ms |
688 KB |
Output is correct |
22 |
Correct |
35 ms |
4672 KB |
Output is correct |
23 |
Correct |
49 ms |
4524 KB |
Output is correct |
24 |
Correct |
44 ms |
4672 KB |
Output is correct |
25 |
Correct |
35 ms |
4672 KB |
Output is correct |
26 |
Correct |
38 ms |
4672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
248 ms |
18000 KB |
Output is correct |
2 |
Correct |
224 ms |
18644 KB |
Output is correct |
3 |
Correct |
255 ms |
17684 KB |
Output is correct |
4 |
Correct |
219 ms |
17812 KB |
Output is correct |
5 |
Correct |
374 ms |
19472 KB |
Output is correct |
6 |
Correct |
1459 ms |
68432 KB |
Output is correct |
7 |
Correct |
340 ms |
22804 KB |
Output is correct |
8 |
Correct |
544 ms |
30224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1409 ms |
82404 KB |
Output is correct |
3 |
Execution timed out |
3042 ms |
284848 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3098 ms |
283588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 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 |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
640 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 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 |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
816 KB |
Output is correct |
20 |
Correct |
7 ms |
688 KB |
Output is correct |
21 |
Correct |
7 ms |
688 KB |
Output is correct |
22 |
Correct |
35 ms |
4672 KB |
Output is correct |
23 |
Correct |
49 ms |
4524 KB |
Output is correct |
24 |
Correct |
44 ms |
4672 KB |
Output is correct |
25 |
Correct |
35 ms |
4672 KB |
Output is correct |
26 |
Correct |
38 ms |
4672 KB |
Output is correct |
27 |
Correct |
11 ms |
1032 KB |
Output is correct |
28 |
Correct |
12 ms |
1072 KB |
Output is correct |
29 |
Correct |
8 ms |
992 KB |
Output is correct |
30 |
Correct |
113 ms |
9056 KB |
Output is correct |
31 |
Correct |
96 ms |
9052 KB |
Output is correct |
32 |
Correct |
92 ms |
9020 KB |
Output is correct |
33 |
Correct |
90 ms |
6624 KB |
Output is correct |
34 |
Correct |
74 ms |
6780 KB |
Output is correct |
35 |
Correct |
86 ms |
6196 KB |
Output is correct |
36 |
Correct |
1459 ms |
83752 KB |
Output is correct |
37 |
Correct |
1528 ms |
83512 KB |
Output is correct |
38 |
Correct |
1564 ms |
83340 KB |
Output is correct |
39 |
Correct |
533 ms |
26064 KB |
Output is correct |
40 |
Correct |
471 ms |
25988 KB |
Output is correct |
41 |
Correct |
449 ms |
25932 KB |
Output is correct |
42 |
Correct |
293 ms |
13904 KB |
Output is correct |
43 |
Correct |
1714 ms |
139328 KB |
Output is correct |
44 |
Correct |
1743 ms |
139352 KB |
Output is correct |
45 |
Correct |
1860 ms |
139252 KB |
Output is correct |
46 |
Correct |
1626 ms |
139376 KB |
Output is correct |
47 |
Correct |
1524 ms |
139660 KB |
Output is correct |
48 |
Correct |
1566 ms |
139568 KB |
Output is correct |
49 |
Correct |
2849 ms |
139600 KB |
Output is correct |
50 |
Correct |
1670 ms |
139452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 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 |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
640 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 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 |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
816 KB |
Output is correct |
20 |
Correct |
7 ms |
688 KB |
Output is correct |
21 |
Correct |
7 ms |
688 KB |
Output is correct |
22 |
Correct |
35 ms |
4672 KB |
Output is correct |
23 |
Correct |
49 ms |
4524 KB |
Output is correct |
24 |
Correct |
44 ms |
4672 KB |
Output is correct |
25 |
Correct |
35 ms |
4672 KB |
Output is correct |
26 |
Correct |
38 ms |
4672 KB |
Output is correct |
27 |
Correct |
248 ms |
18000 KB |
Output is correct |
28 |
Correct |
224 ms |
18644 KB |
Output is correct |
29 |
Correct |
255 ms |
17684 KB |
Output is correct |
30 |
Correct |
219 ms |
17812 KB |
Output is correct |
31 |
Correct |
374 ms |
19472 KB |
Output is correct |
32 |
Correct |
1459 ms |
68432 KB |
Output is correct |
33 |
Correct |
340 ms |
22804 KB |
Output is correct |
34 |
Correct |
544 ms |
30224 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
1409 ms |
82404 KB |
Output is correct |
37 |
Execution timed out |
3042 ms |
284848 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |