# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
253015 | infinite_iq | Circle selection (APIO18_circle_selection) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mp make_pair
#define mid (l+r)/2
#define le node * 2
#define ri node * 2 + 1
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=1e18;
const ll mod=987654321;
const ld Pi=acos(-1);
int n ;
int X [300009] , Y [300009] , R [300009] ;
int ans [300009] ;
int main () {
cin >> n ;
for ( int i = 0 ; i < n ; i ++ ) {
scanf ("%d%d%d", &X [i], &Y [i] , &R [i] ) ;
s1 .ins ( { R [i] , n - i } ) ;
s2 .ins ( { X [i] - R [i] , i } ) ;
s3 .ins ( { X [i] + R [i] , i } ) ;
}
while ( s1 .size () ) {
pi ret = * s1 .rbegin () ;
s1 .era ( ( -- s1.end () ) ) ;
ret .se = n - ret .se ;
int l = X [ret.se] - R [ret.se] , r = X [ret.se] + R [ret.se] ;
vi todel ;
for ( auto it = s2 .lb ( { l , - 1 } ) ; it != s2 .end () ; it ++ ) {
pi crnt = *it ;
if ( crnt .fi > r ) break ;
todel .pb ( crnt .se ) ;
}
for ( auto it = s3 .lb ( { l , - 1 } ) ; it != s3 .end () ; it ++ ) {
pi crnt = *it ;
if ( crnt .fi > r ) break ;
todel .pb ( crnt .se ) ;
}
for ( auto u : todel ) {
if ( s1 .find ( { R [u] , u } ) != s1 .end () )
s1 .era ( { R [u] , u } ) ;
if ( s2 .find ( { X [u] - R [u] , u } ) != s2 .end () )
s2 .era ( { X [u] - R [u] , u } ) ;
if ( s3 .find ( { X [u] + R [u] , u } ) != s3 .end () )
s3 .era ( { X [u] + R [u] , u } ) ;
ans [u] = ret .se ;
}
}
for ( int i = 0 ; i < n ; i ++ ) printf ("%d ", ans [i] + 1 ) ;
cout << endl ;
}