POJ 1468 Rectangles

题目大意:

         在设计超大规模集成电路时通常要测试元件的相互覆盖情况,现假定元件都是长方形,处在一个二维平面内,且各长方形的边和x轴、y轴平行。

         现有多个测例(测例数不确定),每个测例中给出N个长方形(N小于5000),以及各长方形的x的最小值和最大值以及y的最小值和最大值,对于每个测例都要输出被其它长方形整个覆盖的长方形个数。

题目链接

注释代码:

/*                        
 * Problem ID : POJ 1468 Rectangles  
 * Author     : Lirx.t.Una                        
 * Language   : C++              
 * Run Time   : 304 ms                        
 * Run Memory : 1329 KB                        
*/

#include <iostream>
#include <cstdio>

//长方形最大数量
//测试后的最佳数据
#define	MAXRECN		5000

using namespace std;

struct	Rec {//长方形
	
	int		x, y;//最小值
	int		_x, _y;//最大值
	
	Rec(void) {}
	
	friend istream &//输入
	operator>>( istream &is, Rec &rec ) {
		
		is >> rec.x >> rec._x >> rec.y >> rec._y;
		
		return is;
	}
	
	bool
	operator<(Rec &oth) {//a < b表示长方形a被b覆盖
		
		return oth.x  <= x  &&
			   oth._x >= _x &&
			   oth.y  <= y  &&
			   oth._y >= _y;
	}
};

Rec	rec[MAXRECN];

int
main() {
	
	int		n;
	int		cnt;
	
	int		i, j;
	
	while ( ~scanf("%d", &n) ) {
		
		cnt = 0;
		
		for ( i = 0; i < n; i++ )
			cin >> rec[i];
		
		//枚举
		for ( i = 0; i < n; i++ )
			for ( j = 0; j < n; j++ )
				if ( j != i && rec[i] < rec[j] ) {
					
					cnt++;
					break;
				}
				
		printf("%d\n", cnt);
	}
	
	return 0;
}

无注释代码:

#include <iostream>
#include <cstdio>

#define	MAXRECN		5000

using namespace std;

struct	Rec {

	int		x, y;
	int		_x, _y;

	Rec(void) {}

	friend istream &
	operator>>( istream &is, Rec &rec ) {
	
		is >> rec.x >> rec._x >> rec.y >> rec._y;

		return is;
	}

	bool
	operator<(Rec &oth) {
	
		return oth.x  <= x  &&
			   oth._x >= _x &&
			   oth.y  <= y  &&
			   oth._y >= _y;
	}
};

Rec	rec[MAXRECN];

int
main() {
	
	int		n;
	int		cnt;
	
	int		i, j;
	
	while ( ~scanf("%d", &n) ) {
		
		cnt = 0;
		
		for ( i = 0; i < n; i++ )
			cin >> rec[i];
		
		for ( i = 0; i < n; i++ )
			for ( j = 0; j < n; j++ )
				if ( j != i && rec[i] < rec[j] ) {
					
					cnt++;
					break;
				}
				
		printf("%d\n", cnt);
	}
	
	return 0;
}

单词解释:

specialist:n, 专家

VLSI:Very Large Scale Integrated Circuites,超大规模集成电路

component:n, 原件,组件

rectilinear:adj, 直线运动的,呈直线排列的

orient:vt, 导向; adj/n, 东方,东方的

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值