#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
using namespace std;
const int MAXN = 3e5;
int n;
vl end_arr;
bool vis[MAXN];
void print(){
for(int i = 0; i < (int)end_arr.size(); i++)
cout<<end_arr[i]<<" ";
return;
}
class state{
public:
ll x;
ll y;
double radius;
int id;
};
vector<state> arr;
bool state_sort(state left, state right){
if(left.radius < right.radius)
return true;
else if(left.radius == right.radius){
if(left.id > right.id)
return true;
else
return false;
}
else
return false;
}
double get_dist(int x, int y, int x1, int y1){
return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}
void solve(){
int at = 0;
while(at < n){
state current = arr[at];
if(vis[current.id] == false){
vis[current.id] = true;
end_arr[current.id] = current.id + 1;
for(int i = at + 1; i < n; i++){
state check = arr[i];
if(vis[check.id] == false){
double dist = get_dist(current.x, current.y, check.x, check.y);
if(dist <= current.radius + check.radius)
{
end_arr[check.id] = current.id + 1;
vis[check.id] = true;
}
else
continue;
}
else
continue;
}
at++;
}
else
at++;
}
print();
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
memset(vis,false,sizeof(vis));
end_arr.assign(n, 0);
for(int i =0; i < n; i++){
ll a, b;
double c;
cin>>a>>b>>c;
arr.push_back({a,b,c, i});
}
sort(arr.begin(),arr.end(),state_sort);
reverse(arr.begin(),arr.end());
/*for(int i = 0; i < n; i++){
cout<<arr[i].radius<<" "<<arr[i].id<<endl;
}*/
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
313 ms |
25692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
746 ms |
26592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |