#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int M = 3e5+5, MOD = 1e9;
struct circle {int x, y, r, i;};
bool operator<(circle a, circle b) {if (a.r == b.r) return a.i < b.i; return a.r > b.r;};
int p[M];
int sq(int a) {return a*a;}
int dist(circle a, circle b) {
return sq(a.x-b.x) + sq(a.y-b.y);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
set<circle> v;
for (int i = 1; i <= n; i++) {
int x, y, r;
cin >> x >> y >> r;
v.insert({x, y, r, i});
}
while (v.size()) {
auto a = *v.begin();
v.erase(v.begin());
// cout << a.i << ": ";
p[a.i] = a.i;
set<circle> st;
for (auto b:v) {
if (dist(a, b) <= sq(a.r+b.r)) {
p[b.i] = a.i;
// cout << b.i << ' ';
st.insert(b);
}
} //cout << endl;
for (auto c:st) v.erase(c);
}
for (int i = 1; i <= n; i++) cout << p[i] << ' '; cout << endl;
return 0;
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:48:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
48 | for (int i = 1; i <= n; i++) cout << p[i] << ' '; cout << endl;
| ^~~
circle_selection.cpp:48:55: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
48 | for (int i = 1; i <= n; i++) cout << p[i] << ' '; cout << endl;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
508 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
3 ms |
472 KB |
Output is correct |
19 |
Correct |
4 ms |
1228 KB |
Output is correct |
20 |
Correct |
4 ms |
1236 KB |
Output is correct |
21 |
Correct |
6 ms |
1140 KB |
Output is correct |
22 |
Correct |
161 ms |
876 KB |
Output is correct |
23 |
Correct |
172 ms |
872 KB |
Output is correct |
24 |
Correct |
294 ms |
876 KB |
Output is correct |
25 |
Correct |
174 ms |
868 KB |
Output is correct |
26 |
Correct |
186 ms |
868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
552 ms |
53664 KB |
Output is correct |
2 |
Correct |
526 ms |
42996 KB |
Output is correct |
3 |
Correct |
595 ms |
50988 KB |
Output is correct |
4 |
Correct |
578 ms |
54800 KB |
Output is correct |
5 |
Execution timed out |
3028 ms |
29560 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
3054 ms |
11624 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3014 ms |
27256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
508 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
3 ms |
472 KB |
Output is correct |
19 |
Correct |
4 ms |
1228 KB |
Output is correct |
20 |
Correct |
4 ms |
1236 KB |
Output is correct |
21 |
Correct |
6 ms |
1140 KB |
Output is correct |
22 |
Correct |
161 ms |
876 KB |
Output is correct |
23 |
Correct |
172 ms |
872 KB |
Output is correct |
24 |
Correct |
294 ms |
876 KB |
Output is correct |
25 |
Correct |
174 ms |
868 KB |
Output is correct |
26 |
Correct |
186 ms |
868 KB |
Output is correct |
27 |
Correct |
9 ms |
2284 KB |
Output is correct |
28 |
Correct |
10 ms |
2248 KB |
Output is correct |
29 |
Correct |
9 ms |
2244 KB |
Output is correct |
30 |
Correct |
805 ms |
1440 KB |
Output is correct |
31 |
Correct |
806 ms |
1420 KB |
Output is correct |
32 |
Correct |
772 ms |
1444 KB |
Output is correct |
33 |
Correct |
130 ms |
20396 KB |
Output is correct |
34 |
Correct |
130 ms |
20324 KB |
Output is correct |
35 |
Correct |
130 ms |
19244 KB |
Output is correct |
36 |
Execution timed out |
3062 ms |
11412 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
508 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
3 ms |
472 KB |
Output is correct |
19 |
Correct |
4 ms |
1228 KB |
Output is correct |
20 |
Correct |
4 ms |
1236 KB |
Output is correct |
21 |
Correct |
6 ms |
1140 KB |
Output is correct |
22 |
Correct |
161 ms |
876 KB |
Output is correct |
23 |
Correct |
172 ms |
872 KB |
Output is correct |
24 |
Correct |
294 ms |
876 KB |
Output is correct |
25 |
Correct |
174 ms |
868 KB |
Output is correct |
26 |
Correct |
186 ms |
868 KB |
Output is correct |
27 |
Correct |
552 ms |
53664 KB |
Output is correct |
28 |
Correct |
526 ms |
42996 KB |
Output is correct |
29 |
Correct |
595 ms |
50988 KB |
Output is correct |
30 |
Correct |
578 ms |
54800 KB |
Output is correct |
31 |
Execution timed out |
3028 ms |
29560 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |