### Jarjit_sigh's blog

By Jarjit_sigh, history, 10 months ago,

Given a set of circles on a Cartesian plane, there are no 2 circles sharing a point. For each circle we want to find the smallest circle that contains it, or report that there is none.

I tried many solutions that works with rectangles, but none can be modified to work with circles. Any suggestions? :(

• +6

 » 9 months ago, # | ← Rev. 4 →   +22 sweepline by x-coordinate. for each circle you keep the interval of y-coordinate that it covers. since no pair of circles intersects, they only swap their relative position when sorted when either of them leave or enter the sweepline, which you can just remove/add them. thus you can maintain a set/treap of the order of the intervals in $O(n*\log_2n)$ time.granted it would not be the most elegant implementation ever, but it *might works.
•  » » 9 months ago, # ^ | ← Rev. 2 →   -7 does it work with every other convex shapes too?
 » 9 months ago, # |   0 When considering the line x = a, you can split the circles that cross through this line into 2 halves: up and down. So you can sort these semicircles as a bracker sequence. For finding the smallest circle that contains the circle c, you can find the semicircle s greater than or equal to up semicircle of c by lower_bound, the result is s or result of s.