#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fr first
#define sc second
struct Circle{
int x,y,r,id;
void read(int i){
cin>>x>>y>>r;
id=i;
}
}a[300005];
bool operator<(Circle a,Circle b){
return a.r>b.r||(a.r==b.r&&a.id<b.id);
}
typedef long long ll;
ll sq(ll x){return x*x;}
ll dist(int x,int y,int x2,int y2){return sq(x-x2)+sq(y-y2);}
bool intersect(Circle a,Circle b){
return dist(a.x,a.y,b.x,b.y)<=sq(a.r+b.r);
}
int n;
int ans[300005];
void subtask1(){
sort(a+1,a+1+n);
for(int i=1;i<=n;i++)
if(!ans[a[i].id])for(int j=1;j<=n;j++)if(!ans[a[j].id]&&intersect(a[i],a[j]))ans[a[j].id]=a[i].id;
for(int i=1;i<=n;i++)printf("%d ",ans[i]);
exit(0);
}
void subtask2(){
set<pair<int,int>>st;
for(int i=1;i<=n;i++){
st.emplace(a[i].x-a[i].r,i);
st.emplace(a[i].x+a[i].r,i);
}
sort(a+1,a+1+n);
for(int i=1;i<=n;i++){
if(ans[a[i].id])continue;
while(true){
auto it=st.lower_bound(make_pair(a[i].x-a[i].r,-2e9));
if(it==st.end())break;
if(it->first>a[i].x+a[i].r)break;
st.erase(*it);
if(ans[it->second])continue;
ans[it->second]=a[i].id;
}
}
for(int i=1;i<=n;i++)printf("%d ",ans[i]);
exit(0);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
bool _subtask2=true;
for(int i=1;i<=n;i++){
a[i].read(i);
_subtask2&=(a[i].y==0);
}
if(n<=5000)subtask1();
else if(_subtask2)subtask2();
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
460 KB |
Output is correct |
20 |
Correct |
4 ms |
460 KB |
Output is correct |
21 |
Correct |
4 ms |
332 KB |
Output is correct |
22 |
Correct |
56 ms |
404 KB |
Output is correct |
23 |
Correct |
56 ms |
400 KB |
Output is correct |
24 |
Correct |
53 ms |
404 KB |
Output is correct |
25 |
Correct |
48 ms |
404 KB |
Output is correct |
26 |
Correct |
48 ms |
416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
800 ms |
36392 KB |
Output is correct |
2 |
Correct |
824 ms |
36500 KB |
Output is correct |
3 |
Correct |
836 ms |
36088 KB |
Output is correct |
4 |
Correct |
803 ms |
36392 KB |
Output is correct |
5 |
Correct |
804 ms |
36176 KB |
Output is correct |
6 |
Correct |
831 ms |
40852 KB |
Output is correct |
7 |
Correct |
789 ms |
40800 KB |
Output is correct |
8 |
Correct |
771 ms |
40744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
44 ms |
1808 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
107 ms |
4936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
460 KB |
Output is correct |
20 |
Correct |
4 ms |
460 KB |
Output is correct |
21 |
Correct |
4 ms |
332 KB |
Output is correct |
22 |
Correct |
56 ms |
404 KB |
Output is correct |
23 |
Correct |
56 ms |
400 KB |
Output is correct |
24 |
Correct |
53 ms |
404 KB |
Output is correct |
25 |
Correct |
48 ms |
404 KB |
Output is correct |
26 |
Correct |
48 ms |
416 KB |
Output is correct |
27 |
Incorrect |
5 ms |
460 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
460 KB |
Output is correct |
20 |
Correct |
4 ms |
460 KB |
Output is correct |
21 |
Correct |
4 ms |
332 KB |
Output is correct |
22 |
Correct |
56 ms |
404 KB |
Output is correct |
23 |
Correct |
56 ms |
400 KB |
Output is correct |
24 |
Correct |
53 ms |
404 KB |
Output is correct |
25 |
Correct |
48 ms |
404 KB |
Output is correct |
26 |
Correct |
48 ms |
416 KB |
Output is correct |
27 |
Correct |
800 ms |
36392 KB |
Output is correct |
28 |
Correct |
824 ms |
36500 KB |
Output is correct |
29 |
Correct |
836 ms |
36088 KB |
Output is correct |
30 |
Correct |
803 ms |
36392 KB |
Output is correct |
31 |
Correct |
804 ms |
36176 KB |
Output is correct |
32 |
Correct |
831 ms |
40852 KB |
Output is correct |
33 |
Correct |
789 ms |
40800 KB |
Output is correct |
34 |
Correct |
771 ms |
40744 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Incorrect |
44 ms |
1808 KB |
Output isn't correct |
37 |
Halted |
0 ms |
0 KB |
- |