#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define intt long long
#define mid (l+r)/2
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
intt n;
cin>>n;
vector<pair<pair<intt,intt>,pair<intt,intt>>>v;
map<intt,intt>m;
for(int i=0;i<n;i++)
{
intt x,y,r;
cin>>x>>y>>r;
v.push_back({{r,-i},{x,y}});
}
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
for(int i=0;i<n;i++)
{
if(!m[i])
{
m[i]=i+1;
intt x=v[i].second.first;
intt y=v[i].second.second;
intt r=v[i].first.first;
for(int j=0;j<n;j++)
{
if(!m[j])
{
intt x1=v[j].second.first;
intt y1=v[j].second.second;
intt r1=v[j].first.first;
intt h=(x-x1)*(x-x1)+(y-y1)*(y-y1);
if(h<=r*r)
{
m[j]=i+1;
}
}
}
}
}
for(auto u:m)
cout<<u.second<<" ";
return 0;
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:39:26: warning: unused variable 'r1' [-Wunused-variable]
39 | intt r1=v[j].first.first;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
298 ms |
29092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3047 ms |
28380 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |