fjnu 1057 Rectangles

Description

A specialist in VLSI design testing must decide if there are some components that cover each other for a given design. A component is represented as a rectangle. Assume that each rectangle is rectilinearly oriented (sides parallel to the x and y axis), so that the representation of a rectangle consists of its minimum and maximum x and y coordinates.
Write a program that counts the rectangles that are entirely covered by another rectangle.

Input

The input contains the text description of several sets of rectangles. The specification of a set consists of the number of rectangles in the set and the list of rectangles given by the minimum and maximum x and y coordinates separated by white spaces, in the format:

nr_rectangles
xmin1 xmax1 ymin1 ymax1
xmin2 xmax2 ymin2 ymax2
...
xminn xmaxn yminn ymaxn

For each set,there will be less than 5000 rectangles.

Output

The output should be printed on the standard output. For each given input data set, print one integer number in a single line that gives the result (the number of rectangles that are covered).

Sample Input

 
  

Sample Output

 
  
 
  
 
  
Source:

#include
< stdio.h >

int  x1[ 5001 ],x2[ 5001 ],y1[ 5001 ],y2[ 5001 ];
int  n;

void  input()
{
    
int i;
    
for(i=1;i<=n;i++)
    
{
        scanf(
"%d%d%d%d",&x1[i],&x2[i],&y1[i],&y2[i]);
    }

}


int  main()
{
/*    freopen("fjnu_1057.in","r",stdin);*/
    
int i,j;
    
int t;
    
while(scanf("%d",&n)!=EOF)
    
{
        t
=0;
        input();
        
for(i=1;i<=n;i++)
            
for(j=1;j<=n;j++)
            
{
                
if(i!=j&&(x1[j]<=x1[i]&&y1[j]<=y1[i]&&x2[j]>=x2[i]&&y2[j]>=y2[i]))
                
{
                    t
++;
                    
break;
                }

            }

        printf(
"%d ",t);
    }

    
return 0;
}


你可能感兴趣的:(☆ACM,解题报告☆)