#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
#define ll long long
#define ff first
#define ss second
int n, jog[N];
bool vis[N];
struct coordinate {
ll x, y, r, idx;
};
coordinate a[N];
bool intersect (coordinate x, coordinate y) {
ll a1 = (x.x - y.x) * (x.x - y.x), a2 = (x.y - y.y) * (x.y - y.y), a3 = (x.r + y.r) * (x.r + y.r);
return (a1 + a2 <= a3);
}
//void cykar (coordinate x) {
// cout << x.x << " " << x.y << " " << x.r << " " << x.idx << "\n";
//}
bool cmp (coordinate x, coordinate y) {
if (x.r > y.r) return 1;
else if (x.r == y.r and x.idx < y.idx) return 1;
return 0;
}
int main () {
// freopen ("input.txt", "r", stdin);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].x >> a[i].y >> a[i].r;
a[i].idx = i;
}
sort (a + 1, a + n + 1, cmp);
// for (int i = 1; i <= n; ++i) {
// cykar(a[i]);
// }
// cout << "\n\n";
for (int i = 1; i <= n; ++i) {
if (vis[i]) continue;
jog[a[i].idx] = a[i].idx;
for (int j = i + 1; j <= n; ++j) {
if (vis[j]) continue;
if (intersect (a[i], a[j])) {
jog[a[j].idx] = a[i].idx;
vis[j] = 1;
}
}
}
for (int i = 1; i <= n; ++i) {
cout << jog[i] << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
604 KB |
Output is correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Correct |
5 ms |
708 KB |
Output is correct |
22 |
Correct |
22 ms |
748 KB |
Output is correct |
23 |
Correct |
21 ms |
752 KB |
Output is correct |
24 |
Correct |
23 ms |
604 KB |
Output is correct |
25 |
Correct |
21 ms |
604 KB |
Output is correct |
26 |
Correct |
21 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
267 ms |
20052 KB |
Output is correct |
2 |
Correct |
263 ms |
20048 KB |
Output is correct |
3 |
Correct |
267 ms |
20016 KB |
Output is correct |
4 |
Correct |
262 ms |
20048 KB |
Output is correct |
5 |
Correct |
2778 ms |
17712 KB |
Output is correct |
6 |
Execution timed out |
3061 ms |
16096 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
428 KB |
Output is correct |
2 |
Execution timed out |
3051 ms |
6848 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3062 ms |
17728 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 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
604 KB |
Output is correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Correct |
5 ms |
708 KB |
Output is correct |
22 |
Correct |
22 ms |
748 KB |
Output is correct |
23 |
Correct |
21 ms |
752 KB |
Output is correct |
24 |
Correct |
23 ms |
604 KB |
Output is correct |
25 |
Correct |
21 ms |
604 KB |
Output is correct |
26 |
Correct |
21 ms |
604 KB |
Output is correct |
27 |
Correct |
10 ms |
1112 KB |
Output is correct |
28 |
Correct |
10 ms |
1116 KB |
Output is correct |
29 |
Correct |
10 ms |
1116 KB |
Output is correct |
30 |
Correct |
76 ms |
856 KB |
Output is correct |
31 |
Correct |
75 ms |
1104 KB |
Output is correct |
32 |
Correct |
93 ms |
1116 KB |
Output is correct |
33 |
Correct |
103 ms |
7760 KB |
Output is correct |
34 |
Correct |
103 ms |
7684 KB |
Output is correct |
35 |
Correct |
101 ms |
7504 KB |
Output is correct |
36 |
Execution timed out |
3039 ms |
6756 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
604 KB |
Output is correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Correct |
5 ms |
708 KB |
Output is correct |
22 |
Correct |
22 ms |
748 KB |
Output is correct |
23 |
Correct |
21 ms |
752 KB |
Output is correct |
24 |
Correct |
23 ms |
604 KB |
Output is correct |
25 |
Correct |
21 ms |
604 KB |
Output is correct |
26 |
Correct |
21 ms |
604 KB |
Output is correct |
27 |
Correct |
267 ms |
20052 KB |
Output is correct |
28 |
Correct |
263 ms |
20048 KB |
Output is correct |
29 |
Correct |
267 ms |
20016 KB |
Output is correct |
30 |
Correct |
262 ms |
20048 KB |
Output is correct |
31 |
Correct |
2778 ms |
17712 KB |
Output is correct |
32 |
Execution timed out |
3061 ms |
16096 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |