Question about rectangle containment problem.

Правка en1, от empaktus, 2025-08-15 06:26:06

I was trying to solve 2024 Argentinian Programming Tournament (TAP) problem H (https://codeforces.me/gym/105321) and got stuck on a subproblem, but the contest doesn't have an editorial.

I have N axis-aligned rectangles that don't intersect each other (not even at corners), but some can be nested inside others. I need to efficiently find the "parent" of each rectangle, meaning the smallest rectangle that completely contains it. The trivial approach would be O(N^2): for each rectangle, check all others to see which contain it, but this would be too slow. I was thinking about sweep line algorithms but I can't figure it out.

Is there a standard algorithm for this problem?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский empaktus 2025-08-15 06:26:06 731 Initial revision (published)