In the sport of rectangle counting, participants are given a set of
The other day, Angie was invited to judge one of the competitions and now has to produce the correct answer for today's set of
Constraints
Note that the corners of the
Note the difference in constraints above.
Subtask 1 [15%]
Subtask 2 [85%]
No additional constraints.
Input Specification
The first line of input contains the integer
The next
Output Specification
Output the number of pairs of rectangles that intersect with one another. Note that two pairs
Sample Input
4
1 7 10 12
5 3 15 9
14 5 16 10
16 1 17 20
Sample Output
2
Sample Explanation
The intersecting pairs of rectangles are:
Note that the pairs
Furthermore, even though the pair
Comments
If a rectangle is contained entirely within another and their perimeters do not intersect, do they still count as an intersecting pair? For example, {(1, 1), (5, 5)} and {(3, 3), (4, 4)}.
for those wondering, the answer to this question is yes. i think a better description of the problem is to count the number of overlapping pairs.