제출 #263804

#제출 시각아이디문제언어결과실행 시간메모리
263804dsjong원 고르기 (APIO18_circle_selection)C++14
12 / 100
914 ms60880 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define F first #define S second int ans[300005]; int x[300005], y[300005], r[300005]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; vector<pii>v; multiset<pii, greater<pii>>s1; multiset<pii>s2; for(int i=1;i<=n;i++){ cin>>x[i]>>y[i]>>r[i]; v.push_back({r[i], -i}); s1.insert({x[i]-r[i], i}); s2.insert({x[i]+r[i], i}); } sort(v.begin(), v.end()); while(!v.empty()){ int cur=-v.back().S; v.pop_back(); if(ans[cur]) continue; int lb=x[cur]-r[cur], rb=x[cur]+r[cur]; auto it=s2.lower_bound({lb, -1}); while(it!=s2.end()){ auto idx=it->S; if(x[idx]+r[idx]>rb) break; s2.erase(it++); if(ans[idx]) continue; ans[idx]=cur; } auto it1=s1.lower_bound({rb, 1e9}); while(it1!=s1.end()){ auto idx=it1->S; if(x[idx]-r[idx]<lb) break; s1.erase(it1++); if(ans[idx]) continue; ans[idx]=cur; } } for(int i=1;i<=n;i++){ cout<<ans[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...