# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106498 | puyu_liao | Circle selection (APIO18_circle_selection) | C++14 | 3092 ms | 20132 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>
#define pii pair<int, int>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef complex<long double> C;
const int MX = 3e5 + 100;
struct circle { C p; int r, i; } v[MX];
int ans[MX];
main () {
srand(time(0));
int n; cin >> n;
for(int i = 1; i <= n; i ++) {
int x, y, r; cin >> x >> y >> r;
v[i] = {{x, y}, r, i};
}
for(int i = 1; i <= n; i ++) v[i].p *= C{cos(rand()), sin(rand())};
sort(v + 1, v + 1 + n, [](circle a, circle b) { return a.p.X < b.p.X; });
priority_queue<pii> pq;
for(int i = 1; i <= n; i ++) pq.push({v[i].r, -i});
while(pq.size()) {
pii p = pq.top(); pq.pop();
p.S = -p.S;
if(ans[v[p.S].i]) continue;
for(int i = max(1, p.S - 5000); i <= min(n, p.S + 5000); i ++) {
if(!ans[v[i].i] and abs(v[p.S].p - v[i].p) <= v[p.S].r + v[i].r) ans[v[i].i] = v[p.S].i;
}
}
for(int i = 1; i <= n; i ++) cout << ans[i] << ' ';
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
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... |