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>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
struct circle{
int x, y, r, id;
bool operator<(const circle& a)const{
return x < a.x || (x == a.x && id < a.id);
}
};
int dist(circle& a, circle& b){
int x = a.x - b.x;
int y = a.y - b.y;
return x * x + y * y;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<circle> X;
vector<circle> data;
int n;
cin >> n;
vector<int> ans(n, -1);
for(int i = 0; i < n; i++){
int x, y, r;
cin >> x >> y >> r;
X.pb({x, y, r, i});
data.pb({x, y, r, i});
}
sort(all(data), [&](circle a, circle b){return a.r > b.r || (a.r == b.r && a.id < b.id);});
for(auto c : data){
if(ans[c.id] >= 0) continue;
for(auto p : X){
if(ans[p.id] >= 0) continue;
if(dist(c, p) <= (c.r + p.r) * (c.r + p.r)){
ans[p.id] = c.id;
}
}
}
for(int i = 0; i < n; i++){
cout << ans[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... |