Блог пользователя Jarjit_sigh

Автор Jarjit_sigh, история, 5 лет назад, По-английски

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
  • Проголосовать: не нравится

»
5 лет назад, # |
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.

»
5 лет назад, # |
  Проголосовать: нравится 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.