#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll>pil;
const int N=3e5+5;
int n, ans[N], x[N], y[N], r[N];
pii a[N];
bool cmp(const pii &h, const pii &f){
if(h.F!=f.F)
return h.F>f.F;
return h.S<f.S;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=0;i<n;++i){
cin>>x[i]>>y[i]>>r[i];
a[i]={r[i], i};
}
sort(a, a+n, cmp);
vector<int>v;
ans[a[0].S]=a[0].S;
v.push_back(a[0].S);
for(int i=1;i<n;++i){
int j=a[i].S;
ans[j]=j;
for(int k=0;k<v.size();++k){
ll h=x[j]-x[v[k]];
ll f=y[j]-y[v[k]];
ll z=r[j]+r[v[k]];
h*=h;
f*=f;
z*=z;
if(h+f<=z){
ans[j]=v[k];
break;
}
}
if(ans[j]==j)
v.push_back(j);
}
for(int i=0;i<n;++i)
cout<<ans[i]+1<<' ';
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int k=0;k<v.size();++k){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
600 KB |
Output is correct |
20 |
Correct |
3 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
600 KB |
Output is correct |
22 |
Correct |
37 ms |
620 KB |
Output is correct |
23 |
Correct |
38 ms |
624 KB |
Output is correct |
24 |
Correct |
50 ms |
628 KB |
Output is correct |
25 |
Correct |
40 ms |
644 KB |
Output is correct |
26 |
Correct |
52 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
185 ms |
16116 KB |
Output is correct |
2 |
Correct |
174 ms |
16064 KB |
Output is correct |
3 |
Correct |
145 ms |
15804 KB |
Output is correct |
4 |
Correct |
150 ms |
16160 KB |
Output is correct |
5 |
Correct |
1656 ms |
13848 KB |
Output is correct |
6 |
Execution timed out |
3098 ms |
12256 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
3029 ms |
5828 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3042 ms |
14676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
600 KB |
Output is correct |
20 |
Correct |
3 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
600 KB |
Output is correct |
22 |
Correct |
37 ms |
620 KB |
Output is correct |
23 |
Correct |
38 ms |
624 KB |
Output is correct |
24 |
Correct |
50 ms |
628 KB |
Output is correct |
25 |
Correct |
40 ms |
644 KB |
Output is correct |
26 |
Correct |
52 ms |
636 KB |
Output is correct |
27 |
Correct |
6 ms |
852 KB |
Output is correct |
28 |
Correct |
6 ms |
840 KB |
Output is correct |
29 |
Correct |
5 ms |
856 KB |
Output is correct |
30 |
Correct |
145 ms |
900 KB |
Output is correct |
31 |
Correct |
132 ms |
892 KB |
Output is correct |
32 |
Correct |
134 ms |
972 KB |
Output is correct |
33 |
Correct |
50 ms |
6284 KB |
Output is correct |
34 |
Correct |
53 ms |
6348 KB |
Output is correct |
35 |
Correct |
49 ms |
6192 KB |
Output is correct |
36 |
Execution timed out |
3066 ms |
5620 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
600 KB |
Output is correct |
20 |
Correct |
3 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
600 KB |
Output is correct |
22 |
Correct |
37 ms |
620 KB |
Output is correct |
23 |
Correct |
38 ms |
624 KB |
Output is correct |
24 |
Correct |
50 ms |
628 KB |
Output is correct |
25 |
Correct |
40 ms |
644 KB |
Output is correct |
26 |
Correct |
52 ms |
636 KB |
Output is correct |
27 |
Correct |
185 ms |
16116 KB |
Output is correct |
28 |
Correct |
174 ms |
16064 KB |
Output is correct |
29 |
Correct |
145 ms |
15804 KB |
Output is correct |
30 |
Correct |
150 ms |
16160 KB |
Output is correct |
31 |
Correct |
1656 ms |
13848 KB |
Output is correct |
32 |
Execution timed out |
3098 ms |
12256 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |