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

3
100 101 100 101
0 3 0 101
20 40 10 400
4
10 20 10 20
10 20 10 20
10 20 10 20
10 20 10 20

Sample Output

0
4
KEY:这题我用了比较土的办法,不过还是过了,有点慢就是了……呵呵

  
  
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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值