This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |