#include <bits/stdc++.h>
using namespace std;
int n;
struct circle {
int x, y, r, idx;
};
const bool operator>(const circle& lhs, const circle& rhs) {
if (lhs.r != rhs.r) return lhs.r > rhs.r;
return lhs.idx < rhs.idx;
}
const bool operator<(const circle& lhs, const circle& rhs) {
if (lhs.r != rhs.r) return lhs.r < rhs.r;
return lhs.idx > rhs.idx;
}
bool inter(const circle& a, const circle& b) {
long long dist = (a.x - b.x) * 1ll * (a.x - b.x) + (a.y - b.y) * 1ll * (a.y - b.y);
return dist <= (a.r + b.r) * 1ll * (a.r + b.r);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
priority_queue<circle> pq;
vector<circle> v;
for (int i = 0; i < n; i++) {
int x, y, r;
cin >> x >> y >> r;
pq.push({x, y, r, i});
v.push_back({x, y, r, i});
}
vector<int> ans(n);
for (int i = 0; i < n; i++) ans[i] = i;
while (!pq.empty()) {
circle cur = pq.top();
pq.pop();
if (ans[cur.idx] != cur.idx) continue;
for (int i = 0; i < n; i++) {
if (i != cur.idx) {
if (inter(cur, v[i])) {
ans[v[i].idx] = cur.idx;
}
}
}
}
for (int i = 0; i < n; i++) {
if (i) cout << ' ';
cout << ans[i] + 1;
}
cout << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
432 KB |
Output is correct |
5 |
Correct |
2 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
584 KB |
Output is correct |
7 |
Correct |
2 ms |
584 KB |
Output is correct |
8 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
312 ms |
13312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
13312 KB |
Output is correct |
2 |
Execution timed out |
3017 ms |
13312 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3026 ms |
13312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
432 KB |
Output is correct |
5 |
Correct |
2 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
584 KB |
Output is correct |
7 |
Correct |
2 ms |
584 KB |
Output is correct |
8 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
432 KB |
Output is correct |
5 |
Correct |
2 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
584 KB |
Output is correct |
7 |
Correct |
2 ms |
584 KB |
Output is correct |
8 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |