#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 5e3 + 10;
bool done[N];
int n, ans[N], x[N], y[N], r[N];
int solveTestCase() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i] >> r[i];
for (int i = 0; i < n; i++) {
pair<int, int> best = {1e18, 1e18};
for (int j = 0; j < n; j++) {
if (!done[j])
best = min(best, {-r[j], j});
}
if (best.first == 1e18)
break;
for (int j = 0,ind = best.second; j < n; j++) {
if (done[j])
continue;
int dist = (x[ind] - x[j]) * (x[ind] - x[j]) + (y[ind] - y[j]) * (y[ind] - y[j]);
if (dist <= (r[ind] + r[j]) * (r[ind] + r[j]))
ans[j] = ind + 1, done[j] = true;;
}
}
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
return 0;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--)
solveTestCase();
}
Compilation message
circle_selection.cpp: In function 'long long int solveTestCase()':
circle_selection.cpp:32:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
32 | for (int i = 0; i < n; i++)
| ^~~
circle_selection.cpp:34:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
34 | return 0;
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
640 KB |
Output is correct |
20 |
Correct |
3 ms |
640 KB |
Output is correct |
21 |
Correct |
3 ms |
640 KB |
Output is correct |
22 |
Correct |
152 ms |
680 KB |
Output is correct |
23 |
Correct |
148 ms |
640 KB |
Output is correct |
24 |
Correct |
163 ms |
760 KB |
Output is correct |
25 |
Correct |
153 ms |
640 KB |
Output is correct |
26 |
Correct |
148 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Runtime error |
5 ms |
1280 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
640 KB |
Output is correct |
20 |
Correct |
3 ms |
640 KB |
Output is correct |
21 |
Correct |
3 ms |
640 KB |
Output is correct |
22 |
Correct |
152 ms |
680 KB |
Output is correct |
23 |
Correct |
148 ms |
640 KB |
Output is correct |
24 |
Correct |
163 ms |
760 KB |
Output is correct |
25 |
Correct |
153 ms |
640 KB |
Output is correct |
26 |
Correct |
148 ms |
640 KB |
Output is correct |
27 |
Runtime error |
5 ms |
1152 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
640 KB |
Output is correct |
20 |
Correct |
3 ms |
640 KB |
Output is correct |
21 |
Correct |
3 ms |
640 KB |
Output is correct |
22 |
Correct |
152 ms |
680 KB |
Output is correct |
23 |
Correct |
148 ms |
640 KB |
Output is correct |
24 |
Correct |
163 ms |
760 KB |
Output is correct |
25 |
Correct |
153 ms |
640 KB |
Output is correct |
26 |
Correct |
148 ms |
640 KB |
Output is correct |
27 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |