Submission #49967

#TimeUsernameProblemLanguageResultExecution timeMemory
49967zetapiCircle selection (APIO18_circle_selection)C++14
0 / 100
1178 ms109008 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define int long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=4e5; const int INF=1e9; set<pii> st; set<pii> itr it; priority_queue<pii> pq; pii cur; int N,X[MAX],Y[MAX],R[MAX],mark[MAX],par[MAX]; signed main() { ios_base::sync_with_stdio(false); /*cin.tie(0); cout.tie(0);*/ cin>>N; for(int A=1;A<=N;A++) { cin>>X[A]>>Y[A]>>R[A]; X[A]=X[A]-R[A]; Y[A]=X[A]+R[A]+R[A]; pq.push(mp(R[A],-A)); } for(int A=1;A<=N;A++) { st.insert(mp(X[A],A)); st.insert(mp(Y[A],A)); } while(!pq.empty()) { cur=pq.top(); pq.pop(); cur.second*=-1; if(mark[cur.second]) continue; par[cur.second]=cur.second; st.erase(st.find(mp(X[cur.second],cur.second))); st.erase(st.find(mp(Y[cur.second],cur.second))); while(true) { if(st.empty()) break; it=st.lower_bound(mp(X[cur.second],-INF)); if(X[it->second]>Y[cur.second]) break; mark[it->second]=1; par[it->second]=cur.second; st.erase(it); } } for(int A=1;A<=N;A++) cout<<par[A]<<" "; 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...