# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
265487 | DS007 | Circle selection (APIO18_circle_selection) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct circle {
int x, y, r, i;
circle() {
x = y = r = i = 0;
}
bool operator < (circle c) {
if (r == c.r)
return i < c.i;
return r > c.r;
}
};
const int N = 3e5;
circle c[N];
bool done[N];
int n, ans[N];
int solveTestCase() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> c[i].x >> c[i].y >> c[i].r, c[i].i = i + 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if ((c[j].r < c[j + 1].r) || (c[j].r == c[j + 1].r && c[j].i > c[j + 1].i)) {
circle temp = c[j].r;
c[j].r + c[j + 1].r;
c[j + 1].r = temp;
}
}
}
for (int i = 0; i < n; i++) {
if (done[i])
continue;
ans[c[i].i] = c[i].i;
for (int j = i + 1; j < n; j++) {
int dist = (c[i].y - c[j].y) * (c[i].y - c[j].y) + (c[i].x - c[j].x) * (c[i].x - c[j].x);
if (dist <= (c[i].r + c[j].r) * (c[i].r + c[j].r))
done[j] = true, ans[c[j].i] = c[i].i;
}
}
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--)
solveTestCase();
}