This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <set>
using namespace std;
#define int long long
const int N = 3e5 + 10;
int x[N];
int y[N];
int r[N];
int erased[N];
int dist(int i,int j){
int xd = x[i] - x[j];
int yd = y[i] - y[j];
return xd * xd + yd * yd;
}
void sub1(int n){
set<pair<int,int>> s;
for (int i=1;i<=n;i++)
s.insert({-r[i],i});
while (s.size() > 0){
int i = (*begin(s)).second;
for (int j=1;j<=n;j++)
if (!erased[j] and dist(i,j) <= (r[i] + r[j]) * (r[i] + r[j])){
s.erase({-r[j],j});
erased[j] = i;
}
}
for (int i=1;i<=n;i++)
cout<<erased[i]<<' ';
cout<<'\n';
exit(0);
}
signed main(){
int n;
cin>>n;
for (int i=1;i<=n;i++)
cin>>x[i]>>y[i]>>r[i];
if (n <= 5000)
sub1(n);
}
// 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |