uva--221--Urban Elevations

本文详细介绍了如何通过暴力判断的方法解决100个房子在特定场景下的可见性问题,包括如何处理多个房子共同遮挡一个房子的情况。文中还提供了具体的代码实现,帮助读者理解并解决类似问题。

哈哈哈,劳资终于过了这题了

没算法,就100个房子,暴力判断能不能被挡住。

注意一个房子可能被几个房子一起挡住的就情况就可以了,就这这种情况搞了我好几个小时。。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define maxn 120
using namespace std;
struct Build
{
    int x,y;
    int wd,dep,height;
}p[maxn];
int ans[maxn],ic;
int n;
bool init()
{
    scanf("%d",&n);
    ic=0;
    return n;
}
int cmpBuild(Build a,Build b)
{
    return a.x<b.x;
}
bool visible(int d)
{
    Build u,fr[maxn];
    Build a=p[d];
    int right_most=-1;
    bool pab;
    int fc=0;
    for(int i=1;i<=n;i++)
    {
        u=p[i];
        //if(i==d)continue;
        if(u.y>=a.y)continue;
        int mid=u.x;
        pab=mid>=a.x&&mid<=(a.x+a.wd);
        mid=u.x+u.wd;
        pab=pab||(mid>=a.x&&mid<=(a.x+a.wd));
        pab=pab||(u.x<=a.x&&(u.x+u.wd>=a.x+a.wd));
        if(pab&&a.height<=u.height)
        {
            fr[fc++]=u;
            right_most=max(right_most,u.x+u.wd);
        }
    }
    if(fc==0)return true;
    sort(fr,fr+fc,cmpBuild);
    if(fr[0].x>a.x||right_most<(a.x+a.wd))return true;
    right_most=fr[0].x+fr[0].wd;
    for(int i=1;i<fc;i++)
    {
        if(fr[i].x>right_most)return true;
        right_most=max(right_most,fr[i].x+fr[i].wd);
    }
    return false;
}
int cmp(int i,int j)
{
    Build a=p[i];
    Build b=p[j];
    if(a.x==b.x)
    {
        return a.y<b.y;
    }
    else
    {
        return a.x<b.x;
    }
}
int solve()
{
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d%d%d",&p[i].x,&p[i].y,&p[i].wd,&p[i].dep,&p[i].height);
    }
    for(int i=1;i<=n;i++)
    {
        if(visible(i))
        {
            ans[ic++]=i;
        }
    }
    sort(ans,ans+ic,cmp);
    return ic;
}

int main()
{
    //freopen("221.txt","r",stdin);
    int ks=1;
    while(init())
    {
        if(ks!=1)printf("\n");
        printf("For map #%d, the visible building%s are numbered as follows:\n",ks++,solve()==1?"s":"s");
        for(int i=0;i<ic;i++)
        {
            printf("%d",ans[i]);
            if(i!=ic-1)printf(" ");
            else printf("\n");
        }
    }
    return 0;
}

### HEC-RAS One-Dimensional River Cross-Section Modeling and Analysis Tools HEC-RAS (Hydrologic Engineering Center's River Analysis System) is a comprehensive software package used for hydraulic modeling, including the creation of one-dimensional river cross-section models. The toolset within HEC-RAS allows users to analyze water flow through rivers by dividing them into discrete sections or reaches where each section can be modeled as a series of cross-sectional profiles. #### Defining Cross Sections To define a cross section in HEC-RAS, detailed topographic data must be inputted that describes the shape and dimensions of the channel at various points along its length. This includes specifying bank stations, thalweg lines, and elevations across the width of the streambed. These inputs are crucial because they determine how accurately the model will simulate floodplain inundation during high flows[^1]. ```python # Example Python code snippet showing how elevation data might be processed before being imported into HEC-RAS. import numpy as np def process_elevation_data(elevations): """ Process raw elevation measurements from surveying equipment. Args: elevations (list): List containing float values representing measured heights above datum. Returns: list: Cleaned up set of elevation readings ready for import into HEC-RAS. """ cleaned_elevations = [] for e in elevations: if not np.isnan(e): cleaned_elevations.append(round(float(e), 2)) return cleaned_elevations ``` #### Setting Up Computational Parameters Once all necessary geometric information has been entered, computational parameters such as roughness coefficients need setting according to local conditions like vegetation type or substrate material present on site. Manning’s n value represents this coefficient which influences velocity distribution throughout the reach under consideration. #### Running Simulations After configuring both geometry and physics settings appropriately, simulations may commence using steady-state methods suitable for long-term planning studies concerning infrastructure development around riparian zones affected by seasonal variations in discharge rates. During these runs, adjustments made via control structures—such as weirs or spillways—can help mitigate potential risks associated with extreme weather events leading either excessive flooding downstream areas or insufficient supply upstream reservoirs. #### Post-Processing Results Following completion of simulation cycles, post-processing steps involve interpreting output files generated by HEC-RAS. Users often visualize results graphically alongside tabular summaries highlighting key performance indicators relevant to project objectives outlined earlier stages when initiating study scope discussions among stakeholders involved parties interested outcomes derived therefrom.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值