1468 Rectangles
来源:互联网 发布:关键词优化有什么用 编辑:程序博客网 时间:2024/05/01 03:36
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
*******************************************************************************
***********************************************************************************
////现根据面积,选出面积最大的,并插入排序 并保存原始的数据下标!!!!再搜索一下符合条件的#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;}
04
3100 101 100 1010 3 0 10120 40 10 400410 20 10 2010 20 10 2010 20 10 2010 20 10 20
- 1468 Rectangles
- poj 1468 Rectangles
- poj 1468 Rectangles
- POJ 1468 Rectangles
- POJ 1468 Rectangles 笔记
- Rectangles
- Rectangles
- Rectangles
- Rectangles
- Rectangles
- zoj 1139 || poj 1468 Rectangles
- Rectangles dp
- Packing Rectangles
- Packing Rectangles
- Packing Rectangles
- Packing Rectangles
- Packing Rectangles
- Rectangles 2056
- .net三层结构的简单理解
- 设置OpenGL编程环境
- 1597
- 1519 Digital Roots
- 1503 Integer Inquiry
- 1468 Rectangles
- 1432 Decoding Morse Sequences
- JBuilder中使用SQL server 2000时的配置步骤
- 1313 Booklet Printing
- 1251 Jungle Roads
- 浅谈数据库设计技巧(转经典)
- 1239 Increasing Sequences
- 网站栏目
- 1176 Party Lamps