#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] ;
set < pi > s1 , s2 , s3 ;
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] , n - u } ) != s1 .end () )
s1 .era ( { R [u] , n - 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 ;
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:42:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d%d", &X [i], &Y [i] , &R [i] ) ;
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1821 ms |
49128 KB |
Output is correct |
2 |
Correct |
1829 ms |
56196 KB |
Output is correct |
3 |
Correct |
1806 ms |
55704 KB |
Output is correct |
4 |
Correct |
1734 ms |
56548 KB |
Output is correct |
5 |
Correct |
1557 ms |
53956 KB |
Output is correct |
6 |
Correct |
1459 ms |
54008 KB |
Output is correct |
7 |
Correct |
1504 ms |
54136 KB |
Output is correct |
8 |
Correct |
1477 ms |
54088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1157 ms |
49020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |