#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 20;
const int inf = 1e9;
int c[maxn], r[maxn], p[maxn];
vector<int> g[maxn];
int dis(int x, int y, int X, int Y){
return (x-X)*(x-X) + (y-Y)*(y-Y);
}
int x[maxn], y[maxn];
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> x[i] >> y[i] >> r[i];
for (int i = 1; i <= n; i++)
for (int j = i+1; j <= n; j++)
if (dis(x[i],y[i],x[j],y[j]) <= 1ll * (r[i]+r[j])*(r[i]+r[j])){
g[j].push_back(i);
g[i].push_back(j);
}
for (int i = 1; i <= n; i++)
p[i] = i;
sort(p+1, p+n+1, [](int a, int b){
if (r[a] != r[b])
return r[a] > r[b];
return a < b;
});
for (int za = 1; za <= n; za++){
int i = p[za];
if (c[i] != 0)
continue;
c[i] = i;
for (auto j : g[i])
if (!c[j])
c[j] = i;
}
for (int i = 1; i <= n; i++)
cout << c[i] << " \n"[i == n];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
85 ms |
8952 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 |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
86 ms |
8440 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 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |