#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5001;
vector<int> adj[N];
ll who[N];
void solve()
{
ll n;
cin>>n;
vector<ll> x(n),y(n),r(n);
for(int i=0;i<n;i++)
cin>>x[i]>>y[i]>>r[i];
for(int i=0;i<n;i++)
{
for(int j=0;j<=i;j++)
{
// ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) <= (r1+r2)²
ll dist=(r[i]+r[j])*(r[i]+r[j]);
ll dp=( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
if(dp<=dist)
{
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
set<pair<int,int>> rem;
for(int i=0;i<n;i++)
rem.insert({-r[i],i});
while(rem.size())
{
auto p=*begin(rem);
rem.erase(begin(rem));
if(who[p.second]!=0)
continue;
for(auto op:adj[p.second])
if(who[op]==0)
who[op]=p.second+1;
}
for(int i=0;i<n;i++)
{
cout<<who[i]<<' ';
}
cout<<'\n';
}
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
4444 KB |
Output is correct |
17 |
Correct |
6 ms |
4188 KB |
Output is correct |
18 |
Correct |
5 ms |
4700 KB |
Output is correct |
19 |
Correct |
213 ms |
138372 KB |
Output is correct |
20 |
Correct |
201 ms |
136324 KB |
Output is correct |
21 |
Correct |
163 ms |
77912 KB |
Output is correct |
22 |
Correct |
26 ms |
1196 KB |
Output is correct |
23 |
Correct |
26 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
1104 KB |
Output is correct |
25 |
Correct |
26 ms |
1112 KB |
Output is correct |
26 |
Correct |
31 ms |
1204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
393 ms |
266156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
53 ms |
8776 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
96 ms |
23124 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
4444 KB |
Output is correct |
17 |
Correct |
6 ms |
4188 KB |
Output is correct |
18 |
Correct |
5 ms |
4700 KB |
Output is correct |
19 |
Correct |
213 ms |
138372 KB |
Output is correct |
20 |
Correct |
201 ms |
136324 KB |
Output is correct |
21 |
Correct |
163 ms |
77912 KB |
Output is correct |
22 |
Correct |
26 ms |
1196 KB |
Output is correct |
23 |
Correct |
26 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
1104 KB |
Output is correct |
25 |
Correct |
26 ms |
1112 KB |
Output is correct |
26 |
Correct |
31 ms |
1204 KB |
Output is correct |
27 |
Runtime error |
261 ms |
198488 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
4444 KB |
Output is correct |
17 |
Correct |
6 ms |
4188 KB |
Output is correct |
18 |
Correct |
5 ms |
4700 KB |
Output is correct |
19 |
Correct |
213 ms |
138372 KB |
Output is correct |
20 |
Correct |
201 ms |
136324 KB |
Output is correct |
21 |
Correct |
163 ms |
77912 KB |
Output is correct |
22 |
Correct |
26 ms |
1196 KB |
Output is correct |
23 |
Correct |
26 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
1104 KB |
Output is correct |
25 |
Correct |
26 ms |
1112 KB |
Output is correct |
26 |
Correct |
31 ms |
1204 KB |
Output is correct |
27 |
Runtime error |
393 ms |
266156 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |