#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];
long double dist(long double x1, long double y1, long double x2, long double y2) {
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
bool inter(int i, int j) {
return 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;
for (i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> r[i];
}
for (i = 1; i <= n; i++) {
k = 0;
for (j = 1; j <= n; j++) {
if (r[j] > r[k] && !u[j]) k = j;
}
u[k] = 1;
ans[k] = k;
for (j = 1; j <= n; j++) {
if (u[j]) continue;
if (inter(k, j)) {
u[j] = 1;
ans[j] = k;
}
}
}
for (i = 1; i <= n; i++) cout << ans[i] << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
464 KB |
Output is correct |
16 |
Correct |
4 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
604 KB |
Output is correct |
19 |
Correct |
80 ms |
800 KB |
Output is correct |
20 |
Correct |
80 ms |
600 KB |
Output is correct |
21 |
Correct |
80 ms |
788 KB |
Output is correct |
22 |
Correct |
156 ms |
768 KB |
Output is correct |
23 |
Correct |
152 ms |
2772 KB |
Output is correct |
24 |
Correct |
151 ms |
788 KB |
Output is correct |
25 |
Correct |
150 ms |
600 KB |
Output is correct |
26 |
Correct |
150 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3038 ms |
16812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
3078 ms |
6464 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3099 ms |
15640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
464 KB |
Output is correct |
16 |
Correct |
4 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
604 KB |
Output is correct |
19 |
Correct |
80 ms |
800 KB |
Output is correct |
20 |
Correct |
80 ms |
600 KB |
Output is correct |
21 |
Correct |
80 ms |
788 KB |
Output is correct |
22 |
Correct |
156 ms |
768 KB |
Output is correct |
23 |
Correct |
152 ms |
2772 KB |
Output is correct |
24 |
Correct |
151 ms |
788 KB |
Output is correct |
25 |
Correct |
150 ms |
600 KB |
Output is correct |
26 |
Correct |
150 ms |
764 KB |
Output is correct |
27 |
Correct |
316 ms |
3076 KB |
Output is correct |
28 |
Correct |
316 ms |
1112 KB |
Output is correct |
29 |
Correct |
316 ms |
1112 KB |
Output is correct |
30 |
Correct |
736 ms |
1060 KB |
Output is correct |
31 |
Correct |
736 ms |
1056 KB |
Output is correct |
32 |
Correct |
743 ms |
3156 KB |
Output is correct |
33 |
Execution timed out |
3041 ms |
6740 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
464 KB |
Output is correct |
16 |
Correct |
4 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
604 KB |
Output is correct |
19 |
Correct |
80 ms |
800 KB |
Output is correct |
20 |
Correct |
80 ms |
600 KB |
Output is correct |
21 |
Correct |
80 ms |
788 KB |
Output is correct |
22 |
Correct |
156 ms |
768 KB |
Output is correct |
23 |
Correct |
152 ms |
2772 KB |
Output is correct |
24 |
Correct |
151 ms |
788 KB |
Output is correct |
25 |
Correct |
150 ms |
600 KB |
Output is correct |
26 |
Correct |
150 ms |
764 KB |
Output is correct |
27 |
Execution timed out |
3038 ms |
16812 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |