`
阿尔萨斯
  • 浏览: 4147663 次
社区版块
存档分类
最新评论

uva 221 - Urban Elevations(暴力枚举)

 
阅读更多

题目链接:uva 221 - Urban Elevations


题目大意:给出n个房子,每个房子给出西南角的坐标x,y,以及宽度w,长度d,高度h。问说从南边看可以看到基座房子。


解题思路:注意一座房子可能被多座房子挡住。暴力枚举,将有可能挡住当前房子的房子记录下来判断。


#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;
const int N = 105;

struct house {
	int x, y, w, d, h, id;
	void get(int f) {
		scanf("%d%d%d%d%d", &x, &y, &w, &d, &h);
		id = f;
	}
}p[N], q[N];
int n;

bool cmp(const house& a, const house& b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}

bool judge (int k) {
	int cn = 0;
	for (int i = 0; i < n; i++) {
		if (i == k || p[i].y >= p[k].y) continue;
		if (p[i].x >= p[k].x + p[k].w) continue;
		if (p[i].x + p[i].w <= p[k].x) continue;
		if (p[k].h > p[i].h) continue;
		q[cn++] = p[i];
	}
	if (cn == 0) return true;
	int tmp = p[k].x;
	sort(q, q + cn, cmp);
	for (int i = 0; i < cn; i++) {
		if (tmp < q[i].x) return true;
		tmp = max(tmp, q[i].x + q[i].w);
	}
	return tmp < p[k].x + p[k].w;
}

void solve () {
	sort(p, p + n, cmp);
	int flag = 0;
	for (int i = 0; i < n; i++) if (judge(i)) {
		if (flag++) printf(" ");
		printf("%d", p[i].id);
	}
	printf("\n");
}

int main () {
	int cas = 0;
	while (scanf("%d", &n) == 1 && n) {
		if (cas) printf("\n");
		for (int i = 0; i < n; i++) p[i].get(i+1);
		printf("For map #%d, the visible buildings are numbered as follows:\n", ++cas);
		solve();
	}
	return 0;
}


分享到:
评论

相关推荐

    go-elevations:用于golang的SRTM解析器

    go-elevations是“航天飞机雷达地形任务”数据的解析器。 它基于python 的现有库 用法 package main import ( "fmt" "net/http" "github.com/tkrajina/go-elevations/geoelevations" ) func main () { srtm , ...

    Elevations SOE

    利用现有的ArcGIS Server服务并不能实现提供高程数据的功能,因此这里需要利用到ArcGI的SOE扩展ArcGIS Server 服务,因此这要求我们自己辨析代码来扩展现有的GIS功能

    雷达技术知识

    elevations off the water surface (Figure 1, Maslov et aI., 2000). Where LiDAR pulses glance the water surface at angles of incidence greater than 53 degrees, a LiDAR pulse is 2 more often lost to ...

    Elevations C++ for CSV-开源

    高程将数据从Excel移至Unix系统。 它将VBA与Cygwin SSH,CGI和HTTP POST连接,以通过管道将其交付给QuantLib C ++服务器。 提供用于处理CSV文件的C ++类和用于C ++类型的字符串。 文件架构定义。

    Danny's Manual Elevations Hack-crx插件

    语言:English 在手动海拔高度中显示付费图像 手动标高手动标高手动标高

    Three-dimensional simulation

    The ANN is a feedforward four layer network employing the sigmoid function as an activator and the back-propagation algorithm for the network learning, using the water level elevations of the ...

    Algorithm-Theoretical-Basis-Document.rar_matlab例程_matlab_

    Derivation of Range and Range Distributions From Laser Pulse Waveform Analysis for Surface Elevations

    SingleDop:单多普勒检索工具包(SingleDop)

    SingleDop自述文件SingleDop是一个用Python编程语言编写的软件模块,它将从真实或模拟的多普勒雷达数据中检索二维低空风。 它模仿以下参考文献中描述的算法功能: Xu等,2006:使用多普勒雷达径向速度观测值进行矢量...

Global site tag (gtag.js) - Google Analytics