#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
const ll N=3e5+5;
ll n;
ll x[N],y[N],r[N];
vector<ll>adj[N],ans(N,0);
vector<bool>used(N,0);
ll dist(ll i,ll j){
return abs(x[i]-x[j])*abs(x[i]-x[j])+abs(y[i]-y[j])*abs(y[i]-y[j]);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n;
vector<pair<ll,ll>>v;
bool Y=true;
for(ll i=1;i<=n;i++){
cin>>x[i]>>y[i]>>r[i];
v.pb({-r[i],i});
Y&=(y[i]==0);
}
sort(all(v));
if(n<=5000){
for(ll i=1;i<=n;i++){
for(ll j=i+1;j<=n;j++){
if(dist(i,j)<=(r[i]+r[j])*(r[i]+r[j])){
adj[i].pb(j);
adj[j].pb(i);
}
}
}
for(auto [R,i]:v){
if(ans[i]>0) continue;
ans[i]=i;
for(ll j:adj[i]){
if(ans[j]==0) ans[j]=i;
}
}
for(ll i=1;i<=n;i++){
cout<<ans[i]<<' ';
}
return 0;
}
if(Y){
set<pair<ll,ll>>ord;
for(ll i=1;i<=n;i++){
ord.insert({x[i],i});
}
vector<ll>del;
for(auto [R,i]:v){
if(ans[i]>0) continue;
del.clear();
auto it=ord.lower_bound({x[i]-r[i],0});
while(it!=ord.end()&&it->ff<=x[i]+r[i]){
del.pb(it->ss);
it++;
}
for(auto j:del){
ans[j]=i;
ord.erase({r[j],j});
}
}
for(ll i=1;i<=n;i++){
cout<<ans[i]<<' ';
}
cout<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
15196 KB |
Output is correct |
2 |
Correct |
3 ms |
15196 KB |
Output is correct |
3 |
Correct |
4 ms |
15196 KB |
Output is correct |
4 |
Correct |
3 ms |
15196 KB |
Output is correct |
5 |
Correct |
3 ms |
15276 KB |
Output is correct |
6 |
Correct |
4 ms |
15452 KB |
Output is correct |
7 |
Correct |
4 ms |
15452 KB |
Output is correct |
8 |
Correct |
4 ms |
15196 KB |
Output is correct |
9 |
Correct |
3 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
15196 KB |
Output is correct |
11 |
Correct |
3 ms |
15196 KB |
Output is correct |
12 |
Correct |
4 ms |
15196 KB |
Output is correct |
13 |
Correct |
3 ms |
15196 KB |
Output is correct |
14 |
Correct |
3 ms |
15196 KB |
Output is correct |
15 |
Correct |
3 ms |
15196 KB |
Output is correct |
16 |
Correct |
12 ms |
23644 KB |
Output is correct |
17 |
Correct |
11 ms |
23128 KB |
Output is correct |
18 |
Correct |
12 ms |
24000 KB |
Output is correct |
19 |
Correct |
261 ms |
269604 KB |
Output is correct |
20 |
Correct |
232 ms |
269916 KB |
Output is correct |
21 |
Correct |
194 ms |
172100 KB |
Output is correct |
22 |
Correct |
19 ms |
15452 KB |
Output is correct |
23 |
Correct |
23 ms |
15548 KB |
Output is correct |
24 |
Correct |
19 ms |
15452 KB |
Output is correct |
25 |
Correct |
22 ms |
15548 KB |
Output is correct |
26 |
Correct |
19 ms |
15552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
415 ms |
54432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
15196 KB |
Output is correct |
2 |
Incorrect |
33 ms |
17368 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
25152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
15196 KB |
Output is correct |
2 |
Correct |
3 ms |
15196 KB |
Output is correct |
3 |
Correct |
4 ms |
15196 KB |
Output is correct |
4 |
Correct |
3 ms |
15196 KB |
Output is correct |
5 |
Correct |
3 ms |
15276 KB |
Output is correct |
6 |
Correct |
4 ms |
15452 KB |
Output is correct |
7 |
Correct |
4 ms |
15452 KB |
Output is correct |
8 |
Correct |
4 ms |
15196 KB |
Output is correct |
9 |
Correct |
3 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
15196 KB |
Output is correct |
11 |
Correct |
3 ms |
15196 KB |
Output is correct |
12 |
Correct |
4 ms |
15196 KB |
Output is correct |
13 |
Correct |
3 ms |
15196 KB |
Output is correct |
14 |
Correct |
3 ms |
15196 KB |
Output is correct |
15 |
Correct |
3 ms |
15196 KB |
Output is correct |
16 |
Correct |
12 ms |
23644 KB |
Output is correct |
17 |
Correct |
11 ms |
23128 KB |
Output is correct |
18 |
Correct |
12 ms |
24000 KB |
Output is correct |
19 |
Correct |
261 ms |
269604 KB |
Output is correct |
20 |
Correct |
232 ms |
269916 KB |
Output is correct |
21 |
Correct |
194 ms |
172100 KB |
Output is correct |
22 |
Correct |
19 ms |
15452 KB |
Output is correct |
23 |
Correct |
23 ms |
15548 KB |
Output is correct |
24 |
Correct |
19 ms |
15452 KB |
Output is correct |
25 |
Correct |
22 ms |
15548 KB |
Output is correct |
26 |
Correct |
19 ms |
15552 KB |
Output is correct |
27 |
Incorrect |
6 ms |
15708 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
15196 KB |
Output is correct |
2 |
Correct |
3 ms |
15196 KB |
Output is correct |
3 |
Correct |
4 ms |
15196 KB |
Output is correct |
4 |
Correct |
3 ms |
15196 KB |
Output is correct |
5 |
Correct |
3 ms |
15276 KB |
Output is correct |
6 |
Correct |
4 ms |
15452 KB |
Output is correct |
7 |
Correct |
4 ms |
15452 KB |
Output is correct |
8 |
Correct |
4 ms |
15196 KB |
Output is correct |
9 |
Correct |
3 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
15196 KB |
Output is correct |
11 |
Correct |
3 ms |
15196 KB |
Output is correct |
12 |
Correct |
4 ms |
15196 KB |
Output is correct |
13 |
Correct |
3 ms |
15196 KB |
Output is correct |
14 |
Correct |
3 ms |
15196 KB |
Output is correct |
15 |
Correct |
3 ms |
15196 KB |
Output is correct |
16 |
Correct |
12 ms |
23644 KB |
Output is correct |
17 |
Correct |
11 ms |
23128 KB |
Output is correct |
18 |
Correct |
12 ms |
24000 KB |
Output is correct |
19 |
Correct |
261 ms |
269604 KB |
Output is correct |
20 |
Correct |
232 ms |
269916 KB |
Output is correct |
21 |
Correct |
194 ms |
172100 KB |
Output is correct |
22 |
Correct |
19 ms |
15452 KB |
Output is correct |
23 |
Correct |
23 ms |
15548 KB |
Output is correct |
24 |
Correct |
19 ms |
15452 KB |
Output is correct |
25 |
Correct |
22 ms |
15548 KB |
Output is correct |
26 |
Correct |
19 ms |
15552 KB |
Output is correct |
27 |
Incorrect |
415 ms |
54432 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |