Submission #982378

#TimeUsernameProblemLanguageResultExecution timeMemory
982378Sir_Ahmed_ImranCircle selection (APIO18_circle_selection)C++17
12 / 100
1039 ms58336 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define N 300001 int x[N]; int r[N]; int a[N]; set<pii> p,q; void solve(){ int n,m; cin>>n; priority_queue<pii> Q; for(int i=1;i<=n;i++){ cin>>x[i]>>m>>r[i]; Q.push({r[i],-i}); p.add({x[i]+r[i],i}); q.add({x[i]-r[i],i}); } m=2e9+7; p.add({m,0}); q.add({m,0}); while(!Q.empty()){ m=-Q.top().ss; if(a[m]){ Q.pop(); continue; } set<int> s; for(auto i=p.lower_bound({x[m]-r[m],0});(*i).ff<=x[m]+r[m];i++){ s.add((*i).ss); a[(*i).ss]=m; } for(auto i=q.lower_bound({x[m]-r[m],0});(*i).ff<=x[m]+r[m];i++){ s.add((*i).ss); a[(*i).ss]=m; } for(auto& i:s){ p.erase({x[i]+r[i],i}); q.erase({x[i]-r[i],i}); } } for(int i=1;i<=n;i++) cout<<a[i]<<' '; } int terminator(){ L0TA; solve(); 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...