Submission #260884

#TimeUsernameProblemLanguageResultExecution timeMemory
260884wiwihoCircle selection (APIO18_circle_selection)C++14
12 / 100
2161 ms74156 KiB
#include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; typedef long long ll; const ll MAX = 2147483647; ll dis(pll a, pll b){ ll x = a.F - b.F; ll y = a.S - b.S; return x * x + y *y ; } struct Comp{ bool operator()(pll a, pll b){ if(a.F == b.F) return a.S < b.S; return a.F > b.F; } }; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<ll, pll>> c(n); for(int i = 0; i < n; i++){ cin >> c[i].S.F >> c[i].S.S >> c[i].F; } vector<int> a(n); set<pll, Comp> pq; set<pll> l, r; for(int i = 0; i < n; i++){ pq.insert(mp(c[i].F, i)); l.insert(mp(c[i].S.F - c[i].F, i)); r.insert(mp(c[i].S.F + c[i].F, i)); } while(!pq.empty()){ int now = pq.begin()->S; a[now] = now; vector<int> tmp; auto it = l.lower_bound(mp(c[now].S.F - c[now].F, -1)); for(auto it2 = it; it2->F <= c[now].S.F + c[now].F; it2++){ if(it2 == l.end()) break; //cerr << "l " << now << " " << it2->F << " " << it2->S << "\n"; tmp.eb(it2->S); } it = r.lower_bound(mp(c[now].S.F + c[now].F, MAX)); it--; for(auto it2 = it; it2->F >= c[now].S.F - c[now].F; it2--){ //cerr << "r " << now << " " << it2->F << " " << it2->S << "\n"; tmp.eb(it2->S); if(it2 == r.begin()) break; } for(int i : tmp){ pq.erase(mp(c[i].F, i)); l.erase(mp(c[i].S.F - c[i].F, i)); r.erase(mp(c[i].S.F + c[i].F, i)); a[i] = now; } } for(int i = 0; i < n; i++) cout << a[i] + 1 << " "; cout << "\n"; return 0; }
#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...