# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
265496 | DS007 | Circle selection (APIO18_circle_selection) | C++14 | 163 ms | 1280 KiB |
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 int long long
const int N = 5e3 + 10;
bool done[N];
int n, ans[N], x[N], y[N], r[N];
int solveTestCase() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i] >> r[i];
for (int i = 0; i < n; i++) {
pair<int, int> best = {1e18, 1e18};
for (int j = 0; j < n; j++) {
if (!done[j])
best = min(best, {-r[j], j});
}
if (best.first == 1e18)
break;
for (int j = 0,ind = best.second; j < n; j++) {
if (done[j])
continue;
int dist = (x[ind] - x[j]) * (x[ind] - x[j]) + (y[ind] - y[j]) * (y[ind] - y[j]);
if (dist <= (r[ind] + r[j]) * (r[ind] + r[j]))
ans[j] = ind + 1, done[j] = true;;
}
}
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
return 0;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--)
solveTestCase();
}
Compilation message (stderr)
# | 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... |