#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef complex<long double> C;
const int MX = 3e5 + 100;
const double EPS = 1e-5;
struct circle { C p; int r, i; } v[MX];
int ans[MX];
bool touch(int a, int b) {
return !ans[v[b].i] and abs(v[b].p - v[a].p) + EPS <= v[a].r + v[b].r;
}
main () {
srand(time(0));
int n; cin >> n;
for(int i = 1; i <= n; i ++) {
int x, y, r; cin >> x >> y >> r;
v[i] = {{x, y}, r, i};
}
int ang = rand();
for(int i = 1; i <= n; i ++) v[i].p *= C{cos(ang), sin(ang)};
sort(v + 1, v + 1 + n, [](circle a, circle b) { return a.p.X < b.p.X; });
priority_queue<pair<int, pii> > pq;
for(int i = 1; i <= n; i ++) pq.push({v[i].r, {-v[i].i, -i}});
while(pq.size()) {
int p = -pq.top().S.S; pq.pop();
if(ans[v[p].i]) continue;
for(int i = max(1, p - 5000); i <= min(n, p + 5000); i ++) {
if(touch(p, i)) ans[v[i].i] = v[p].i;
}
}
for(int i = 1; i <= n; i ++) cout << ans[i] << ' ';
}
Compilation message
circle_selection.cpp:16:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:21:23: warning: narrowing conversion of 'x' from 'int' to 'long double' inside { } [-Wnarrowing]
v[i] = {{x, y}, r, i};
^
circle_selection.cpp:21:23: warning: narrowing conversion of 'y' from 'int' to 'long double' inside { } [-Wnarrowing]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14464 KB |
Output is correct |
2 |
Correct |
14 ms |
14464 KB |
Output is correct |
3 |
Correct |
13 ms |
14336 KB |
Output is correct |
4 |
Correct |
13 ms |
14464 KB |
Output is correct |
5 |
Correct |
13 ms |
14464 KB |
Output is correct |
6 |
Correct |
15 ms |
14464 KB |
Output is correct |
7 |
Correct |
15 ms |
14464 KB |
Output is correct |
8 |
Correct |
14 ms |
14464 KB |
Output is correct |
9 |
Correct |
14 ms |
14464 KB |
Output is correct |
10 |
Correct |
16 ms |
14464 KB |
Output is correct |
11 |
Correct |
16 ms |
14464 KB |
Output is correct |
12 |
Correct |
14 ms |
14464 KB |
Output is correct |
13 |
Correct |
16 ms |
14464 KB |
Output is correct |
14 |
Correct |
17 ms |
14484 KB |
Output is correct |
15 |
Correct |
15 ms |
14464 KB |
Output is correct |
16 |
Correct |
16 ms |
14464 KB |
Output is correct |
17 |
Correct |
16 ms |
14464 KB |
Output is correct |
18 |
Correct |
16 ms |
14464 KB |
Output is correct |
19 |
Correct |
24 ms |
14592 KB |
Output is correct |
20 |
Correct |
22 ms |
14720 KB |
Output is correct |
21 |
Correct |
31 ms |
14584 KB |
Output is correct |
22 |
Correct |
722 ms |
14644 KB |
Output is correct |
23 |
Correct |
694 ms |
14644 KB |
Output is correct |
24 |
Correct |
736 ms |
14712 KB |
Output is correct |
25 |
Correct |
745 ms |
14648 KB |
Output is correct |
26 |
Correct |
796 ms |
14712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
646 ms |
21308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
14464 KB |
Output is correct |
2 |
Execution timed out |
3030 ms |
16212 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3088 ms |
20716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14464 KB |
Output is correct |
2 |
Correct |
14 ms |
14464 KB |
Output is correct |
3 |
Correct |
13 ms |
14336 KB |
Output is correct |
4 |
Correct |
13 ms |
14464 KB |
Output is correct |
5 |
Correct |
13 ms |
14464 KB |
Output is correct |
6 |
Correct |
15 ms |
14464 KB |
Output is correct |
7 |
Correct |
15 ms |
14464 KB |
Output is correct |
8 |
Correct |
14 ms |
14464 KB |
Output is correct |
9 |
Correct |
14 ms |
14464 KB |
Output is correct |
10 |
Correct |
16 ms |
14464 KB |
Output is correct |
11 |
Correct |
16 ms |
14464 KB |
Output is correct |
12 |
Correct |
14 ms |
14464 KB |
Output is correct |
13 |
Correct |
16 ms |
14464 KB |
Output is correct |
14 |
Correct |
17 ms |
14484 KB |
Output is correct |
15 |
Correct |
15 ms |
14464 KB |
Output is correct |
16 |
Correct |
16 ms |
14464 KB |
Output is correct |
17 |
Correct |
16 ms |
14464 KB |
Output is correct |
18 |
Correct |
16 ms |
14464 KB |
Output is correct |
19 |
Correct |
24 ms |
14592 KB |
Output is correct |
20 |
Correct |
22 ms |
14720 KB |
Output is correct |
21 |
Correct |
31 ms |
14584 KB |
Output is correct |
22 |
Correct |
722 ms |
14644 KB |
Output is correct |
23 |
Correct |
694 ms |
14644 KB |
Output is correct |
24 |
Correct |
736 ms |
14712 KB |
Output is correct |
25 |
Correct |
745 ms |
14648 KB |
Output is correct |
26 |
Correct |
796 ms |
14712 KB |
Output is correct |
27 |
Incorrect |
32 ms |
14904 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14464 KB |
Output is correct |
2 |
Correct |
14 ms |
14464 KB |
Output is correct |
3 |
Correct |
13 ms |
14336 KB |
Output is correct |
4 |
Correct |
13 ms |
14464 KB |
Output is correct |
5 |
Correct |
13 ms |
14464 KB |
Output is correct |
6 |
Correct |
15 ms |
14464 KB |
Output is correct |
7 |
Correct |
15 ms |
14464 KB |
Output is correct |
8 |
Correct |
14 ms |
14464 KB |
Output is correct |
9 |
Correct |
14 ms |
14464 KB |
Output is correct |
10 |
Correct |
16 ms |
14464 KB |
Output is correct |
11 |
Correct |
16 ms |
14464 KB |
Output is correct |
12 |
Correct |
14 ms |
14464 KB |
Output is correct |
13 |
Correct |
16 ms |
14464 KB |
Output is correct |
14 |
Correct |
17 ms |
14484 KB |
Output is correct |
15 |
Correct |
15 ms |
14464 KB |
Output is correct |
16 |
Correct |
16 ms |
14464 KB |
Output is correct |
17 |
Correct |
16 ms |
14464 KB |
Output is correct |
18 |
Correct |
16 ms |
14464 KB |
Output is correct |
19 |
Correct |
24 ms |
14592 KB |
Output is correct |
20 |
Correct |
22 ms |
14720 KB |
Output is correct |
21 |
Correct |
31 ms |
14584 KB |
Output is correct |
22 |
Correct |
722 ms |
14644 KB |
Output is correct |
23 |
Correct |
694 ms |
14644 KB |
Output is correct |
24 |
Correct |
736 ms |
14712 KB |
Output is correct |
25 |
Correct |
745 ms |
14648 KB |
Output is correct |
26 |
Correct |
796 ms |
14712 KB |
Output is correct |
27 |
Incorrect |
646 ms |
21308 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |