#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int N;
cin>>N;
vector<int> X(N),Y(N),R(N);
for(int i=0;i<N;i++){
cin>>X[i]>>Y[i]>>R[i];
X[i] += (int)(1e9)+2*R[i];
Y[i] += (int)(1e9)+2*R[i];
}
vector<int> A(N,N+1);
vector<pair<int,int>> S(N);
for(int i=0;i<N;i++) S[i] = {R[i],N-1-i};
sort(S.rbegin(),S.rend());
int n = ((int)(2e18)/(2*R[0]))+10;
map<int,set<int>> m;
vector<int> I(N);
for(int i=0;i<N;i++){
m[X[i]/(2*R[0])*n+Y[i]/(2*R[i])].insert(i);
I[i] = X[i]/(2*R[0])*n+Y[i]/(2*R[i]);
}
for(int i=0;i<N;i++){
int ind = N-1-S[i].second;
if(A[ind] != N+1) continue;
int pos = I[ind];
for(int x:m[pos]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos+1]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos+1].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos-1]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos-1].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos+n]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos+n].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos+n+1]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos+n+1].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos+n-1]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos+n-1].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos-n]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos-n].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos-n+1]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos-n+1].erase(x);
A[x] = ind+1;
}
}
for(int x:m[pos-n-1]){
if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
m[pos-n-1].erase(x);
A[x] = ind+1;
}
}
}
for(int i=0;i<N;i++) cout<<A[i]<<' ';
cout<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
407 ms |
62668 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
607 ms |
119456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |