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.








