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 <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
using ll = long long;
const int maxn = (int)3e5+10;
const ll LINF = (ll)2e18;
struct circle{
int x, y, r, i;
};
int n, elim[maxn];
vector<circle> v;
int dis(int i, int j){
return (v[i].x-v[j].x)*(v[i].x-v[j].x)+(v[i].y-v[j].y)*(v[i].y-v[j].y);
}
bool intersects(int i, int j){
return (v[i].r+v[j].r)*(v[i].r+v[j].r)>=dis(i,j);
}
int32_t main(){
cin >> n; v.resize(n);
for(int i = 0; i < n; i++){
cin >> v[i].x >> v[i].y >> v[i].r; v[i].i=i; elim[v[i].i]=i;
}
sort(all(v), [&](circle a, circle b){
if(a.r!=b.r) return a.r > b.r;
return a.i < b.i;
});
for(int i = 0; i < n; i++){
if(elim[v[i].i]!=v[i].i) continue;
for(int j = i+1; j < n; j++)
if(intersects(i,j)) elim[v[j].i]=v[i].i;
}
for(int i = 0; i < n; i++) cout << elim[i]+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... |