# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
797394 | radaiosm7 | Circle selection (APIO18_circle_selection) | C++98 | 3085 ms | 19632 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 X first
#define Y second
int n, i, j, curr, chk;
long long R1, R2;
int ans[300005];
pair<long long, int> rd[300005];
pair<long long, long long> pnt[300005];
bool cmp(const pair<long long, int>& a, const pair<long long, int>& b) {
if (a.X == b.X) return a.Y < b.Y;
else return a.X > b.X;
}
bool val(int x, int y) {
return (pnt[x].X-pnt[y].X)*(pnt[x].X-pnt[y].X) + (pnt[x].Y-pnt[y].Y)*(pnt[x].Y-pnt[y].Y) <= (R1+R2)*(R1+R2);
}
int main() {
scanf("%d", &n);
for (i=1; i <= n; ++i) {
scanf("%lld%lld%lld", &pnt[i].X, &pnt[i].Y, &rd[i].X);
rd[i].Y = i;
}
sort(rd+1, rd+n+1, cmp);
fill(ans, ans+n+1, -1);
for (i=1; i <= n; ++i) {
curr = rd[i].Y;
R1 = rd[i].X;
if (ans[curr] == -1) {
ans[curr] = curr;
for (j=i+1; j <= n; ++j) {
chk = rd[j].Y;
R2 = rd[j].X;
if (ans[chk] == -1 && val(curr, chk)) ans[chk] = curr;
}
}
}
for (i=1; i < n; ++i) printf("%d ", ans[i]);
printf("%d\n", ans[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... |