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;
long double dist(long long x, long long y, long long xx, long long yy) {
return sqrtl((x - xx) * (x - xx) + (y - yy) * (y - yy));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> x(n), y(n), r(n);
set<pair<int, int>> ms;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i] >> r[i];
ms.insert({-r[i], i});
}
vector<int> a(n, -1);
while (!ms.empty()) {
int jj = ms.begin()->second;
a[jj] = jj;
ms.erase(ms.begin());
for (int i = 0; i < n; i++) {
if (a[i] == -1) {
if (dist(x[i], y[i], x[jj], y[jj]) <= (long double) r[i] + r[jj]) {
a[i] = jj;
ms.erase({-r[i], i});
}
}
}
}
for (const auto& xx : a) {
cout << xx + 1 << " ";
}
cout << '\n';
return 0;
}
# | 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... |