Submission #980779

#TimeUsernameProblemLanguageResultExecution timeMemory
980779UnforgettableplCircle selection (APIO18_circle_selection)C++17
0 / 100
3 ms860 KiB
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> adj[5001]; pair<int,pair<int,int>> circles[5001]; int ans[5001]; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...