#include <bits/stdc++.h>
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
#define pii pair<int, int>
#define fr first
#define sc second
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define mk make_pair
using namespace std;
const int MAXN = (int)3e5 + 5;
int n;
int x[MAXN];
int y[MAXN];
int rad[MAXN];
vector <int> g[MAXN];
double get_dist(int i, int j) {
return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
}
bool intersect(int i, int j) {
return (get_dist(i, j) <= (rad[i] + rad[j]) * (rad[i] + rad[j]));
}
int ans[MAXN];
signed main() {
fastInp;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> rad[i];
}
vector <int> pos;
for (int i = 1; i <= n; i++) {
pos.pb(i);
}
sort(all(pos), [&](int A, int B) {
if (rad[A] != rad[B]) {
return rad[A] > rad[B];
} else {
return A < B;
}
});
memset(ans, -1, sizeof(ans));
for (int el : pos) {
if (ans[el] == -1) {
ans[el] = el;
for (int i = 1; i <= n; i++) {
if (ans[i] == -1 && intersect(i, el)) {
ans[i] = el;
}
}
}
}
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
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8524 KB |
Output is correct |
2 |
Incorrect |
5 ms |
8524 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
180 ms |
22120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8524 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
155 ms |
21848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8524 KB |
Output is correct |
2 |
Incorrect |
5 ms |
8524 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8524 KB |
Output is correct |
2 |
Incorrect |
5 ms |
8524 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |