#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;
else
return 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;
}
UVa 221 Urban Elevations
最新推荐文章于 2024-04-09 14:42:24 发布