UVa 221 Urban Elevations
来源:互联网 发布:中国云计算创新基地 编辑:程序博客网 时间:2024/06/04 18:36
#include<iostream>#include<cstdio>#include<string>#include<map>#include<sstream>#include<algorithm>#include<vector>#include<queue>#include<set>#include<cstring>#include<stack>#include<iomanip>using namespace std;typedef struct{double x,y,w,d,h;int id;}Build;int n;bool compare(const Build &a,const Build &b){if(a.x!=b.x)return a.x<b.x;elsereturn a.y<b.y;}bool cover(int i,double mx,Build temp[]){if(!(temp[i].x<=mx&&temp[i].x+temp[i].w>=mx))return true;for(int j=0;j<n;j++){if(temp[j].x<=mx&&temp[j].x+temp[j].w>=mx&&temp[j].y<temp[i].y&&temp[j].h>=temp[i].h)return true;}return false;}int main(){int kcase=0;while(scanf("%d",&n)!=EOF&&n!=0){Build *building=new Build[n];int i,j;double *width=new double[2*n];for(i=0;i<n;i++){building[i].id=i+1;scanf("%lf %lf %lf %lf %lf",&building[i].x,&building[i].y,&building[i].w,&building[i].d,&building[i].h);width[2*i]=building[i].x;width[2*i+1]=building[i].x+building[i].w;}sort(building,building+n,compare);sort(width,width+2*n);int m=unique(width,width+2*n)-width;if(kcase++)printf("\n");printf("For map #%d, the visible buildings are numbered as follows:\n%d",kcase,building[0].id); for(i=1;i<n;i++){bool vis=false;for(j=0;j<m-1;j++){if(!cover(i,(width[j]+width[j+1])/2.0,building)){vis=true;break;}}if(vis){printf(" %d",building[i].id);}}printf("\n");}return 0;}
0 0
- uva--221--Urban Elevations
- UVA - 221 Urban Elevations
- UVa 221 Urban Elevations
- UVa 221 Urban Elevations
- uva 221 Urban Elevations
- uva 221 Urban Elevations
- uva 221 - Urban Elevations(暴力枚举)
- UVA 221 Urban Elevations 离散化 模拟
- UVa 221 - Urban Elevations (离散化)
- UVA 221 Urban Elevations (离散化)
- UVa 221 Urban Elevations (区间覆盖问题)
- UVA 221 Urban Elevations(离散化)
- UVA 221 Urban Elevations (离散化)
- Urban Elevations UVA
- Urban Elevations UVA
- 221 - Urban Elevations
- UVA 221 - Urban Elevations(枚举+区间覆盖)
- UVa221 - Urban Elevations
- ubuntu 14.04 mysql change datadir
- Ruby基础教程(三)——类和模块
- hdoj5676ztr loves lucky numbers
- 写单机看看 简单的splite3
- 使用FormData对包含文件类型的form表单进行异步提交(文件上传)并配置回调
- UVa 221 Urban Elevations
- 谈谈墨迹天气app v5.8.4的用户体验1
- Iterator遍历集合特点
- first step
- php关于数字格式方法收集
- JSP
- Vb生成一定范围内的随机数(含小数部分)
- [笔记] 代码学习速率:跟上开源的步伐
- wamp下codeigniter报500错误的问题