이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |