Untidy Desktops
Time Limit:10000MS Memory Limit:65536K
Total Submit:0 Accepted:0
Description
Many companies are moving towards “paperless offices" in an attempt to increase productivity. Un-
fortunately, people who are unorganized with papers are unorganized without papers too! Instead of having piles of paper scattered all over a desk, people have windows overlapping and covering one an-other. For these people, finding the right window on the computer screen is just as hard as finding the right piece of paper on the desk.
For this problem, you will be given the locations and sizes of n windows on a computer desktop (1≤N≤50). You have been asked to evaluate how untidy the computer desktop is by counting the number of windows that overlap with at least one other window. Two windows overlap if at least one pixel is in both windows (including the boundary of the windows).
Input
The input will consist of multiple cases. Each case will start with a line containing a single integer n. This will be followed by n lines of the form
r c w h
where r, c are the row and column coordinates of the upper left corner of the window, and w, h are the width and height of the window. You may assume that the upper left corner of the computer desktop has coordinates (0,0), the screen has 1024 rows and 1280 columns, and all windows are completely within the boundary of the screen. A value of n = 0 will terminate the input.
Output
For each test case, print on a single line the number of windows that overlap with at least one other window.
Sample Input
3
0 0 20 20
20 20 20 20
40 40 20 20
5
0 0 20 20
18 18 20 20
40 40 20 20
5 10 4 2
100 100 40 40
0
Sample Output
0
3
[此贴子已经被作者于2007-11-2 13:57:01编辑过]