#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int64_t//int_fast64_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),cout.tie(0),ios_base::sync_with_stdio(false)
#define f2(x) ((x)*(x))
const int maxn=3e5+9,inf=1ll<<60,bl=3e9;
struct C{int x,y,r,id;}a[maxn];
int n,rmv[maxn],res[maxn];
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=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])continue;
C c=a[*it];
if(f2(a[i].x-c.x)+f2(a[i].y-c.y)<=f2(a[i].r+c.r)){
res[c.id]=a[i].id;
rmv[*it]=1;
}
}
}
}
REP(i,0,n)cout<<res[i]+1<<" ";
}
Compilation message
circle_selection.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
4 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 |
2 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 |
764 KB |
Output is correct |
20 |
Correct |
5 ms |
768 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
36 ms |
4744 KB |
Output is correct |
23 |
Correct |
29 ms |
4616 KB |
Output is correct |
24 |
Correct |
23 ms |
4744 KB |
Output is correct |
25 |
Correct |
28 ms |
4744 KB |
Output is correct |
26 |
Correct |
34 ms |
4744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
225 ms |
16896 KB |
Output is correct |
2 |
Correct |
184 ms |
17892 KB |
Output is correct |
3 |
Correct |
201 ms |
18908 KB |
Output is correct |
4 |
Correct |
226 ms |
17000 KB |
Output is correct |
5 |
Correct |
277 ms |
21780 KB |
Output is correct |
6 |
Correct |
1325 ms |
70792 KB |
Output is correct |
7 |
Correct |
367 ms |
25196 KB |
Output is correct |
8 |
Correct |
558 ms |
32580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
640 KB |
Output is correct |
2 |
Correct |
1352 ms |
83132 KB |
Output is correct |
3 |
Execution timed out |
3041 ms |
286460 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3061 ms |
290180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
4 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 |
2 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 |
764 KB |
Output is correct |
20 |
Correct |
5 ms |
768 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
36 ms |
4744 KB |
Output is correct |
23 |
Correct |
29 ms |
4616 KB |
Output is correct |
24 |
Correct |
23 ms |
4744 KB |
Output is correct |
25 |
Correct |
28 ms |
4744 KB |
Output is correct |
26 |
Correct |
34 ms |
4744 KB |
Output is correct |
27 |
Correct |
9 ms |
1024 KB |
Output is correct |
28 |
Correct |
13 ms |
1024 KB |
Output is correct |
29 |
Correct |
10 ms |
984 KB |
Output is correct |
30 |
Correct |
98 ms |
9052 KB |
Output is correct |
31 |
Correct |
93 ms |
9016 KB |
Output is correct |
32 |
Correct |
99 ms |
9016 KB |
Output is correct |
33 |
Correct |
66 ms |
6764 KB |
Output is correct |
34 |
Correct |
72 ms |
6796 KB |
Output is correct |
35 |
Correct |
64 ms |
6196 KB |
Output is correct |
36 |
Correct |
1496 ms |
84652 KB |
Output is correct |
37 |
Correct |
1323 ms |
84344 KB |
Output is correct |
38 |
Correct |
1293 ms |
84216 KB |
Output is correct |
39 |
Correct |
550 ms |
26728 KB |
Output is correct |
40 |
Correct |
583 ms |
26712 KB |
Output is correct |
41 |
Correct |
582 ms |
26800 KB |
Output is correct |
42 |
Correct |
153 ms |
14596 KB |
Output is correct |
43 |
Correct |
1675 ms |
140224 KB |
Output is correct |
44 |
Correct |
1726 ms |
140388 KB |
Output is correct |
45 |
Correct |
1640 ms |
140272 KB |
Output is correct |
46 |
Correct |
1518 ms |
140232 KB |
Output is correct |
47 |
Correct |
1586 ms |
140356 KB |
Output is correct |
48 |
Correct |
1595 ms |
140360 KB |
Output is correct |
49 |
Correct |
1692 ms |
140456 KB |
Output is correct |
50 |
Correct |
1711 ms |
140280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
4 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 |
2 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 |
764 KB |
Output is correct |
20 |
Correct |
5 ms |
768 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
36 ms |
4744 KB |
Output is correct |
23 |
Correct |
29 ms |
4616 KB |
Output is correct |
24 |
Correct |
23 ms |
4744 KB |
Output is correct |
25 |
Correct |
28 ms |
4744 KB |
Output is correct |
26 |
Correct |
34 ms |
4744 KB |
Output is correct |
27 |
Correct |
225 ms |
16896 KB |
Output is correct |
28 |
Correct |
184 ms |
17892 KB |
Output is correct |
29 |
Correct |
201 ms |
18908 KB |
Output is correct |
30 |
Correct |
226 ms |
17000 KB |
Output is correct |
31 |
Correct |
277 ms |
21780 KB |
Output is correct |
32 |
Correct |
1325 ms |
70792 KB |
Output is correct |
33 |
Correct |
367 ms |
25196 KB |
Output is correct |
34 |
Correct |
558 ms |
32580 KB |
Output is correct |
35 |
Correct |
2 ms |
640 KB |
Output is correct |
36 |
Correct |
1352 ms |
83132 KB |
Output is correct |
37 |
Execution timed out |
3041 ms |
286460 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |