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 int long long
using namespace std;
int n, i, j, k, x[300001], y[300001], r[300001], ans[300001];
bool u[300001];
long double dist(long double x1, long double y1, long double x2, long double y2) {
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
bool inter(int i, int j) {
return r[i] + r[j] >= dist(x[i], y[i], x[j], y[j]);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n;
for (i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> r[i];
}
for (i = 1; i <= n; i++) {
k = 0;
for (j = 1; j <= n; j++) {
if (r[j] > r[k] && !u[j]) k = j;
}
u[k] = 1;
ans[k] = k;
for (j = 1; j <= n; j++) {
if (u[j]) continue;
if (inter(k, j)) {
u[j] = 1;
ans[j] = k;
}
}
}
for (i = 1; i <= n; i++) cout << ans[i] << " ";
}
# | 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... |