# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658746 | 600Mihnea | Circle selection (APIO18_circle_selection) | C++17 | 3018 ms | 15508 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.
bool home = 0;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (int) 3e5 + 7;
int n;
struct Circle {
int x;
int y;
int r;
};
bool doIntersect(Circle a, Circle b) {
/// dist <= a.r + b.r
/// dist ^ 2 <= (a.r + b.r) ^ 2
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) <= (a.r + b.r) * (a.r + b.r);
}
Circle circles[N];
int ret[N];
int main() {
if (home == 0) {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
} else {
freopen ("input.txt", "r", stdin);
}
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> circles[i].x >> circles[i].y >> circles[i].r;
}
vector<int> inds(n);
iota(inds.begin(), inds.end(), 1);
while ((int) inds.size() >= 1) {
int best = inds[0];
for (auto &ind : inds) {
if (circles[ind].r > circles[best].r || (circles[ind].r == circles[best].r && ind < best)) {
best = ind;
}
}
vector<int> newInds;
for (auto &ind : inds) {
if (doIntersect(circles[ind], circles[best])) {
ret[ind] = best;
} else {
newInds.push_back(ind);
}
}
inds = newInds;
}
for (int i = 1; i <= n; i++) {
cout << ret[i] << " ";
}
cout << "\n";
return 0;
}
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... |