이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define vi vector<int>
#define pb emplace_back
#define fi first
#define se second
#define all(n) (n).begin(),(n).end()
#define mem(n,m) memset(n,m,sizeof(n))
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);
template<typename A> void _do(A x){cerr<<x<<'\n';}
template<typename A,typename ...B> void _do(A x,B ...y){cerr<<x<<", ";_do(y...);}
struct circle{
ll x, y, r, id;
bool operator<(const circle &b){
if(r!=b.r) return r>b.r;
return id<b.id;
}
}arr[300005];
int n, del[300005], fr[300005], ba[300005];
bool in(ll i,ll j){
ll R = arr[i].r + arr[j].r;
ll dx = arr[i].x - arr[j].x, dy = arr[i].y - arr[j].y;
return dx*dx + dy*dy <= R*R;
}
set<pii> s;
signed main(){
IOS;
cin>>n;
for(int i=1;i<=n;i++){
cin>>arr[i].x>>arr[i].y>>arr[i].r;
arr[i].id = i;
s.insert({arr[i].x - arr[i].r, i});
s.insert({arr[i].x + arr[i].r, i});
}
sort(arr+1,arr+1+n);
for(int i=1;i<=n;i++){
if(del[arr[i].id]) continue;
//dbg(arr[i].id);
auto iter = s.lower_bound({arr[i].x-arr[i].r,-1});
while(iter!=s.end() && iter->fi <= arr[i].x + arr[i].r ){
//dbg(iter->fi, iter->se);
if(!del[iter->se]) del[iter->se] = arr[i].id;
iter = s.erase(iter);
}
del[arr[i].id] = arr[i].id;
}
for(int i=1;i<=n;i++) cout<<del[i]<<" \n"[i==n];
}
/*
11
9 0 2
13 0 1
11 0 2
3 0 2
3 0 1
12 0 1
9 0 5
2 0 2
5 0 1
14 0 2
14 0 1
*/
# | 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... |