Submission #673854

#TimeUsernameProblemLanguageResultExecution timeMemory
673854Dan4LifeCircle selection (APIO18_circle_selection)C++17
7 / 100
3095 ms39628 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define int long long #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() using ll = long long; const int maxn = (int)3e5+10; const ll LINF = (ll)2e18; struct circle{ int x, y, r, i; }; int n, elim[maxn]; vector<circle> v; bool intersects(int i, int j){ int rr = v[i].r+v[j].r; int xx = v[i].x-v[j].x; int yy = v[i].y-v[j].y; return rr*rr>=xx*xx+yy*yy; } int32_t main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n; v.resize(n); set<pair<int,int>> S; for(int i = 0; i < n; i++){ cin >> v[i].x >> v[i].y >> v[i].r; v[i].i=i; elim[i]=-1; S.insert({v[i].x, i}); } sort(all(v), [&](circle a, circle b){ if(a.r!=b.r) return a.r > b.r; return a.i < b.i; }); for(int i = 0; i < n; i++){ if(elim[v[i].i]!=-1) continue; for(int j = i; j < n; j++) if(intersects(i,j) and elim[v[j].i]==-1) elim[v[j].i]=v[i].i; } for(int i = 0; i < n; i++) cout << ++elim[i] << " "; }
#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...