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

Автор u7MTEUAz7UW57MpH, история, 4 года назад, По-русски

During an internship contest I got stuck on this problem:

You are given a set of rectangles with their sides being parallel to x-,y-axes. __ For each rectangle count the number of another rectangles which intersect it properly. Intersection of two rectangles is called proper if it has non-zero area.

Input description: n (1 ≤ n ≤ 100 000) — number of rectangles

In next n lines your are given 4 integer numbers: xL, yL, xR, yR -- coordinates of left-bottom and right-top. (-10^9 ≤ xL, yL, xR, yR ≤ 10^9; xL < xR; yL < yR)

I thought the problem is on sweep-line, but I don't know how to apply it here. My roommate says it's very common problem and the solution something like "sweepline + segment tree", but he does not remember it.

By the way, I tried to google it, nothing found.

Any ideas? Cheers.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится