#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, i, j, k, x[300001], y[300001], r[300001], ans[300001];
bool u[300001];
multiset<pair<int, int>> ms, ms2, ms3, mss;
long double dist(long double x1, long double y1, long double x2, long double y2) {
return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
bool inter(int i, int j) {
return (r[i] + r[j]) * (r[i] + r[j]) >= dist(x[i], y[i], x[j], y[j]);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n;
bool subtask2 = 1;
for (i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> r[i];
y[i] = 0;
ms.insert({r[i], -i});
ms2.insert({abs(x[i] - r[i]), i});
ms3.insert({abs(x[i] - r[i]), i});
//y[i] = 0;
if (y[i] != 0) {
subtask2 = 0;
}
}
if (subtask2) {
for (i = 1; i <= n; i++) {
if (ms.empty()) break;
k = -(*ms.rbegin()).second;
ms.erase(prev(ms.end()));
ms2.erase({abs(x[k] - r[k]), k});
ms3.erase({abs(x[k] - r[k]), k});
ans[k] = k;
while (ms2.size()) {
auto it = ms2.begin();
int j = (*it).second;
if (r[k] + r[j] >= abs(x[j] - x[k])) {
ans[j] = k;
ms.erase({r[j], -j});
ms2.erase(ms2.begin());
ms3.erase({abs(x[j] - r[j]), j});
}
else break;
}
while (ms3.size()) {
auto it = ms3.begin();
int j = (*it).second;
if (r[k] + r[j] >= abs(x[j] - x[k])) {
ans[j] = k;
ms.erase({r[j], -j});
ms2.erase({abs(x[j] - r[j]), j});
ms3.erase(ms3.begin());
}
else break;
}
}
for (i = 1; i <= n; i++) cout << ans[i] << " ";
return 0;
}
for (i = 1; i <= n; i++) {
if (ms.empty()) break;
k = -(*ms.rbegin()).second;
ms.erase(prev(ms.end()));
ans[k] = k;
for (auto j : ms) {
if (inter(k, -j.second)) {
ans[-j.second] = k;
}
else mss.insert(j);
}
ms = mss;
mss.clear();
}
for (i = 1; i <= n; i++) cout << ans[i] << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
1 ms |
8540 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1018 ms |
68356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
8540 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
725 ms |
68096 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
1 ms |
8540 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
1 ms |
8540 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |