#include <bits/stdc++.h>
using namespace std;
#define int long long
pair<int,pair<int,int>> circles[300001];
int ans[300001];
bool check(int a,int b){
return (circles[a].first+circles[b].first)*(circles[a].first+circles[b].first)>=(circles[a].second.first-circles[b].second.first)*(circles[a].second.first-circles[b].second.first)+(circles[a].second.second-circles[b].second.second)*(circles[a].second.second-circles[b].second.second);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for(int i=1;i<=n;i++)cin>>circles[i].second.first>>circles[i].second.second>>circles[i].first;
set<pair<int,int>> circle;
set<pair<int,int>> activepos;
for(int i=1;i<=n;i++){
circle.insert({circles[i].first,-i});
activepos.insert({circles[i].second.first-circles[i].first,i});
activepos.insert({circles[i].second.first+circles[i].first,i});
}
auto remove = [&](int x,int p){
if(circle.count({circles[x].first,-x})) {
circle.erase({circles[x].first, -x});
ans[x] = p;
}
};
while(!circle.empty()){
auto curr = *--circle.end();curr.second=-curr.second;
auto iter1 = activepos.lower_bound({circles[curr.second].second.first-circles[curr.second].first,0});
auto iter2 = activepos.lower_bound({circles[curr.second].second.first+circles[curr.second].first+1,0});
while(iter1!=iter2){
remove(iter1->second,curr.second);
iter1=activepos.erase(iter1);
}
}
for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1104 ms |
74624 KB |
Output is correct |
2 |
Correct |
1134 ms |
74924 KB |
Output is correct |
3 |
Correct |
1110 ms |
74508 KB |
Output is correct |
4 |
Correct |
1082 ms |
74992 KB |
Output is correct |
5 |
Correct |
1010 ms |
72632 KB |
Output is correct |
6 |
Correct |
965 ms |
72768 KB |
Output is correct |
7 |
Correct |
1051 ms |
72748 KB |
Output is correct |
8 |
Correct |
1067 ms |
72836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
849 ms |
75280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |