#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector,Ofast")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=3e5+5;
const ld pi=acos(-1);
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
struct circle{
ll r,x,y,id;
bool operator <(circle B){
return (r!=B.r?r>B.r:id<B.id);
}
};
bool inter(circle A,circle B){
return (SQ(A.r+B.r)>=SQ(A.x-B.x)+SQ(A.y-B.y));
}
ll n,ans[N];
vector<circle> cir;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
cir.resize(n);
REP(i,n)cin>>cir[i].x>>cir[i].y>>cir[i].r,cir[i].id=i;
sort(cir.begin(),cir.end());
ll R=cir[0].r+1;
while(SZ(cir)){
vector<pair<pll,ll> > loc;
REP(i,SZ(cir))loc.pb(mp(mp(cir[i].x/R,cir[i].y/R),i));
sort(loc.begin(),loc.end());
for(auto i:cir){
if(ans[i.id])continue;
if(i.r<R/2)break;
ans[i.id]=i.id;
ll cx=i.x/R,cy=i.y/R;
for(int x=cx-2;x<=cx+2;x++){
pair<pll,ll> pos=mp(mp(x,cy-2),-1);
for(int j=lwb(loc.begin(),loc.end(),pos)-loc.begin();j<SZ(loc);j++){
if(loc[j].X.X!=x||loc[j].X.Y>cy+2)break;
if(!ans[cir[loc[j].Y].id]&&inter(i,cir[loc[j].Y])){
ans[cir[loc[j].Y].id]=i.id;
}
}
}
}
vector<circle> tmp=cir;
cir.clear();
for(auto i:tmp){
if(!ans[i.id])cir.pb(i);
}
R>>=1;
}
REP(i,n)cout<<ans[i]+1<<(i==n-1?"\n":" ");
return 0;
}
/*
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
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
204 ms |
35392 KB |
Output is correct |
2 |
Correct |
231 ms |
35264 KB |
Output is correct |
3 |
Correct |
234 ms |
35392 KB |
Output is correct |
4 |
Correct |
229 ms |
35520 KB |
Output is correct |
5 |
Correct |
260 ms |
33260 KB |
Output is correct |
6 |
Correct |
367 ms |
33344 KB |
Output is correct |
7 |
Correct |
268 ms |
33504 KB |
Output is correct |
8 |
Correct |
284 ms |
33472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
493 ms |
36544 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |