#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<long long,long long> point;
struct A {
long long x, y, r;
int i;
bool operator < (const A & o) const {
if (r == o.r) return i < o.i;
return r > o.r;
}
} cir[5050];
int ans[5010];
int mark[5010];
long long dis (point i, point j) {
long long temp = ((i.x-j.x) * (i.x-j.x)) + ((i.y-j.y) * (i.y-j.y));
return temp;
}
bool intersect (A i, A j) {
return (dis({i.x, i.y}, {j.x, j.y}) <= (i.r+j.r)*(i.r+j.r));
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
for (int i = 1; i <= n; i++) {
long long x, y, r; cin >> x >> y >> r;
cir[i] = {x, y, r, i};
}
sort(cir+1, cir+1+n);
for (int i = 1; i <= n; i++) {
int ind = cir[i].i;
cerr << ind << endl;
if (mark[i]) continue;
mark[i] = 1;
ans[ind] = ind;
for (int j = i+1; j <= n; j++) {
if (mark[j]) continue;
int anind = cir[j].i;
if (intersect(cir[i], cir[j])) {
ans[anind] = ind;
mark[j] = 1;
}
}
}
for (int i = 1; i <= n; i++) {
cout << ans[i] << ' ';
} cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
332 KB |
Output is correct |
19 |
Correct |
18 ms |
684 KB |
Output is correct |
20 |
Correct |
18 ms |
680 KB |
Output is correct |
21 |
Correct |
19 ms |
676 KB |
Output is correct |
22 |
Correct |
45 ms |
640 KB |
Output is correct |
23 |
Correct |
45 ms |
588 KB |
Output is correct |
24 |
Correct |
45 ms |
648 KB |
Output is correct |
25 |
Correct |
45 ms |
584 KB |
Output is correct |
26 |
Correct |
47 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1100 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Runtime error |
4 ms |
1100 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1100 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
332 KB |
Output is correct |
19 |
Correct |
18 ms |
684 KB |
Output is correct |
20 |
Correct |
18 ms |
680 KB |
Output is correct |
21 |
Correct |
19 ms |
676 KB |
Output is correct |
22 |
Correct |
45 ms |
640 KB |
Output is correct |
23 |
Correct |
45 ms |
588 KB |
Output is correct |
24 |
Correct |
45 ms |
648 KB |
Output is correct |
25 |
Correct |
45 ms |
584 KB |
Output is correct |
26 |
Correct |
47 ms |
588 KB |
Output is correct |
27 |
Runtime error |
3 ms |
972 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
332 KB |
Output is correct |
19 |
Correct |
18 ms |
684 KB |
Output is correct |
20 |
Correct |
18 ms |
680 KB |
Output is correct |
21 |
Correct |
19 ms |
676 KB |
Output is correct |
22 |
Correct |
45 ms |
640 KB |
Output is correct |
23 |
Correct |
45 ms |
588 KB |
Output is correct |
24 |
Correct |
45 ms |
648 KB |
Output is correct |
25 |
Correct |
45 ms |
584 KB |
Output is correct |
26 |
Correct |
47 ms |
588 KB |
Output is correct |
27 |
Runtime error |
3 ms |
1100 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |