Submission #172299

#TimeUsernameProblemLanguageResultExecution timeMemory
172299eggag32Circle selection (APIO18_circle_selection)C++17
7 / 100
3094 ms30504 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pi; #define debug(x) cerr << #x << ": " << x << endl; #define debug2(x, y) debug(x) debug(y); #define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++) #define rep(i, a) for(int i = 0; i < (int)(a); i++) #define all(v) v.begin(), v.end() #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sq(x) ((x) * (x)) template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); } bool cmp(pair<pair<ld, int>, pair<ld, ld>> a, pair<pair<ld, int>, pair<ld, ld>> b){ if(a.fi.fi != b.fi.fi) return (a.fi.fi > b.fi.fi); return (a.fi.se < b.fi.se); } ld dist(ld x, ld y, ld x1, ld y1){ return sqrtl(sq(x1 - x) + sq(y1 - y)); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); int n; cin >> n; vector<pair<pair<ld, int>, pair<ld, ld>>> c(n); rep(i, n){ cin >> c[i].se.fi >> c[i].se.se >> c[i].fi.fi; c[i].fi.se = i; } sort(all(c), cmp); vi vis(n, 0); vi ans(n, 0); //they are sorted in the way they appear rep(i, n) if(!vis[i]){ repn(j, i + 1, n) if(!vis[j]){ if(dist(c[i].se.fi, c[i].se.se, c[j].se.fi, c[j].se.se) <= (c[i].fi.fi + c[j].fi.fi)){ //they intersect vis[j] = 1; ans[c[j].fi.se] = c[i].fi.se; } } vis[i] = 1; ans[c[i].fi.se] = c[i].fi.se; } rep(i, n) cout << ans[i] + 1 << " "; cout << endl; return 0; } /* Things to look out for: - Integer overflows - Array bounds - Special cases Be careful! */
#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...