Submission #980773

#TimeUsernameProblemLanguageResultExecution timeMemory
980773UnforgettableplCircle selection (APIO18_circle_selection)C++17
7 / 100
250 ms217296 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; for(int i=1;i<=n;i++){ circle.insert({circles[i].first,-i}); adj[i].emplace_back(i); for(int j=1;j<=n;j++){ if(check(i,j))adj[i].emplace_back(j); } } 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; for(int&i:adj[curr.second]){ remove(i,curr.second); } } 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...