#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, 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];
ms.insert({r[i], -i});
//y[i] = 0;
if (y[i] != 0) {
subtask2 = 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] << " ";
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:22:7: warning: variable 'subtask2' set but not used [-Wunused-but-set-variable]
22 | bool subtask2 = 1;
| ^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8656 KB |
Output is correct |
3 |
Correct |
1 ms |
8536 KB |
Output is correct |
4 |
Correct |
1 ms |
8536 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8536 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8536 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8536 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
2 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
4 ms |
9052 KB |
Output is correct |
20 |
Correct |
4 ms |
9052 KB |
Output is correct |
21 |
Correct |
5 ms |
9052 KB |
Output is correct |
22 |
Correct |
1002 ms |
9552 KB |
Output is correct |
23 |
Correct |
1058 ms |
9504 KB |
Output is correct |
24 |
Correct |
991 ms |
9304 KB |
Output is correct |
25 |
Correct |
1040 ms |
9304 KB |
Output is correct |
26 |
Correct |
993 ms |
9404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
280 ms |
38160 KB |
Output is correct |
2 |
Correct |
364 ms |
46816 KB |
Output is correct |
3 |
Correct |
290 ms |
40112 KB |
Output is correct |
4 |
Correct |
269 ms |
37716 KB |
Output is correct |
5 |
Execution timed out |
3021 ms |
52048 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Execution timed out |
3078 ms |
23864 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3007 ms |
55160 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8656 KB |
Output is correct |
3 |
Correct |
1 ms |
8536 KB |
Output is correct |
4 |
Correct |
1 ms |
8536 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8536 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8536 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8536 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
2 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
4 ms |
9052 KB |
Output is correct |
20 |
Correct |
4 ms |
9052 KB |
Output is correct |
21 |
Correct |
5 ms |
9052 KB |
Output is correct |
22 |
Correct |
1002 ms |
9552 KB |
Output is correct |
23 |
Correct |
1058 ms |
9504 KB |
Output is correct |
24 |
Correct |
991 ms |
9304 KB |
Output is correct |
25 |
Correct |
1040 ms |
9304 KB |
Output is correct |
26 |
Correct |
993 ms |
9404 KB |
Output is correct |
27 |
Correct |
6 ms |
9560 KB |
Output is correct |
28 |
Correct |
6 ms |
9564 KB |
Output is correct |
29 |
Correct |
6 ms |
9564 KB |
Output is correct |
30 |
Execution timed out |
3087 ms |
10076 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8656 KB |
Output is correct |
3 |
Correct |
1 ms |
8536 KB |
Output is correct |
4 |
Correct |
1 ms |
8536 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8536 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8536 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8536 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
2 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
4 ms |
9052 KB |
Output is correct |
20 |
Correct |
4 ms |
9052 KB |
Output is correct |
21 |
Correct |
5 ms |
9052 KB |
Output is correct |
22 |
Correct |
1002 ms |
9552 KB |
Output is correct |
23 |
Correct |
1058 ms |
9504 KB |
Output is correct |
24 |
Correct |
991 ms |
9304 KB |
Output is correct |
25 |
Correct |
1040 ms |
9304 KB |
Output is correct |
26 |
Correct |
993 ms |
9404 KB |
Output is correct |
27 |
Correct |
280 ms |
38160 KB |
Output is correct |
28 |
Correct |
364 ms |
46816 KB |
Output is correct |
29 |
Correct |
290 ms |
40112 KB |
Output is correct |
30 |
Correct |
269 ms |
37716 KB |
Output is correct |
31 |
Execution timed out |
3021 ms |
52048 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |