1468 Rectangles

原创 2007年10月15日 08:20:00
Rectangles
Time Limit: 5000MS   Memory Limit: 10000K
Total Submissions: 1187   Accepted: 586

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
Southeastern Europe 2000

 *******************************************************************************

***********************************************************************************

Source Code
////现根据面积,选出面积最大的,并插入排序 并保存原始的数据下标!!!!再搜索一下符合条件的

#include <iostream>
using namespace std;

struct Rectangle
{
int minx;
int maxx;
int miny;
int maxy;
};

int main()
{
int Area[5000],Area1[5000],a[5000];
Rectangle Rec[5000];
int i ,j ,temp ;
int num, Index ,sum;
while(scanf("%d",&num )!=EOF )
{
   for(i=0; i<num; i++)
   {
    scanf("%d %d %d %d", &Rec[i].minx, &Rec[i].maxx, &Rec[i].miny, &Rec[i].maxy );
    Area[i] = ( Rec[i].maxx - Rec[i].minx ) *( Rec[i].maxy-Rec[i].miny);
    Area1[i] =Area[i];
   }

        for(i=0;i<num-1;i++)
     {
           int   min=i;
           for(j = i+1; j < num; j ++)
             if( Area1[j] < Area1[min])
                min = j;
           temp = Area1[min];
           Area1[min] = Area1[i];
           Area1[i] = temp;
     }
     for(i = 0; i < num; i ++)
           for(j=0 ; j < num; j ++)
             if(Area1[i] == Area[j])
             {
                Area[j]=0;
                a[i]=j;
                break;
    }
        for(sum=0,j=0;j<num-1;j++)
          for(i=j+1;i<num;i++)
            if(Rec[a[j]].maxx<=Rec[a[i]].maxx&&Rec[a[j]].minx>=Rec[a[i]].minx
      &&Rec[a[j]].maxy<=Rec[a[i]].maxy&&Rec[a[j]].miny>=Rec[a[i]].miny )
            {     
               sum++;
               break;
     }     
        for(i=0;i<num-1;i++)
           if(Rec[i].maxx==Rec[num-1].maxx && Rec[i].minx==Rec[num-1].minx
     &&Rec[i].maxy==Rec[num-1].maxy&&Rec[i].miny==Rec[num-1].miny)
           {
              sum+=1;
              break;
           }

   printf("%d/n",sum);
}
return 0;
}

 

0
4

 

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

POJ 1468 Rectangles(判定点在平行坐标轴的矩形内)

POJ 1468 Rectangles(判定点在平行坐标轴的矩形内) http://poj.org/problem?id=1468 题意:        给你n个边平行于坐标轴的矩形,问你有多少...
  • u013480600
  • u013480600
  • 2014-09-14 14:29:29
  • 820

POJ 1468 Rectangles 笔记

n个矩形,给出每个矩形最大最小x坐标和y坐标。 求被别的矩形完全覆盖的矩形数。 ...
  • woniupengpeng
  • woniupengpeng
  • 2017-06-20 12:17:50
  • 83

POJ 1468 Rectangles

题目大意: 题目链接 注释代码: 无注释代码: 单词解释:
  • u013569656
  • u013569656
  • 2014-05-04 15:52:43
  • 318

poj 1468 Rectangles

/* Name:poj 1468 Rectangles Author:Unimen Date: 23/04/11 19:27*//*解题报告:1、由时间5000ms,猜测可以用暴力求解2、暴力求...
  • Unimen
  • Unimen
  • 2011-06-18 18:18:00
  • 480

zoj 1139 || poj 1468 Rectangles

判断一个矩形是否在另一个矩形里,直接判断四个点是否在矩形里即可。暴力。。 #include #include #include #include #include #include...
  • zxy_snow
  • zxy_snow
  • 2011-04-28 20:51:00
  • 1391

bzoj1468: Tree 点分治

今天考试,依旧打暴力咯。一看第一题绝壁是个虚树之类的东东。就是给你一棵树每次选几个点,给定几个点的控制范围,统计有多少点被控制。正解是离线+点分治+虚树。搞得我整个人都BB了。不过这场真是暴力出奇迹,...
  • IED98
  • IED98
  • 2015-03-25 19:03:28
  • 668

P - Rectangles

Given two rectangles and the coordinates of two points on the diagonals of each rectangle,you have t...
  • qq_30796379
  • qq_30796379
  • 2017-11-01 21:18:05
  • 125

D - Rectangles

Byteman has a collection of N squares with side 1. How many different rectangles can he form using t...
  • sdnuzsj
  • sdnuzsj
  • 2017-01-23 18:31:31
  • 153

750. Number Of Corner Rectangles

Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectan...
  • zjucor
  • zjucor
  • 2017-12-17 13:01:27
  • 402

交换机划分VLAN

交换机划分VLAN配置 在交换机1上 在交换机2上 在pc1上测试 利用三层交换机实现VLAN间路由 在二层交换机上 在三层交换机上 ...
  • yongchaocsdn
  • yongchaocsdn
  • 2016-12-31 16:44:05
  • 343
收藏助手
不良信息举报
您举报文章:1468 Rectangles
举报原因:
原因补充:

(最多只允许输入30个字)