#include <bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int n;
const int N=5007;
int vis[N],r[N];pair<int,int>a[N];
set<pair<int,int>>s;
bool check(int c1,int c2)
{
int x=a[c1].first-a[c2].first;x*=x;
int y=a[c1].second-a[c2].second;y*=y;
int rr=r[c1]+r[c2];rr*=rr;
if (x+y<=rr)return 1;
return false;
}
void cl(int ind)
{
for(int i=0;i<n;i++)
{
if (vis[i])continue;
if (check(ind,i))
{
s.erase({r[i],-i});
vis[i]=ind+1;
}
}
}
int main()
{
fast
cin>>n;
for(int i=0;i<n;i++)
{
int x,y,z;
cin>>x>>y>>z;
a[i].first=x;a[i].second=y;
r[i]=z;
}
for(int i=0;i<n;i++)
{
s.insert({r[i],-i});
}
while (!s.empty())
{
pair<int,int>x=*s.rbegin();
cl(-x.second);
}
for(int i=0;i<n;i++)cout<<vis[i]<<" ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1016 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
1144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |