이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct Circle {
long long x, y, r;
int i;
Circle(long long _x, long long _y, long long _r, int _i) : x(_x), y(_y), r(_r), i(_i) {
// do nothing
}
bool intercept(const Circle &c) {
long long dx = c.x - x, dy = c.y - y, dr = c.r + r;
// cerr << dx << ' ' << dy << ' ' << dr << '\n';
if (dx * dx * 1LL + dy * dy * 1LL <= dr * dr * 1LL) {
return true;
} else {
return false;
}
}
bool operator < (const Circle &c) {
return r == c.r ? i < c.i : r > c.r;
}
};
const int MAX = 1e5 + 9;
vector<Circle> v;
int parent[MAX];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// Circle c1 = Circle(9, 8, 5, 1);
// Circle c2 = Circle(2, 8, 2, 1);
// cerr << c1.intercept(c2) << '\n';
// return 0;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
parent[i] = i;
}
for (int i = 0; i < n; i++) {
int x, y, r;
cin >> x >> y >> r;
v.emplace_back(x * 1LL, y * 1LL, r * 1LL, i + 1);
}
sort(v.begin(), v.end());
// for (auto vv : v) {
// cerr << vv.i << '\n';
// }
// return 0;
for (auto vv : v) {
if (parent[vv.i] == vv.i) {
for (auto vvv : v) {
if (parent[vvv.i] != vvv.i) {
continue;
}
if (vv.intercept(vvv)) {
parent[vvv.i] = vv.i;
}
}
}
}
for (int i = 1; i <= n; i++) {
cout << parent[i] << ' ';
}
cout << '\n';
return 0;
}
# | 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... |