POJ 1566(toj 1952)

本文介绍了一个利用最短路径算法解决特定几何问题的方法。该问题涉及在一个包含障碍物的房间中寻找两点间最短路径,通过将几何元素转化为图论中的节点和边,并运用最短路径算法求解。文章提供了详细的实现代码及思路解析。
The Doors
Time Limit: 1.0 Seconds    Memory Limit: 65536K
Total Runs: 126    Accepted Runs: 69



The Problem

You are to find the length of the shortest path through a chamber containing obstructing walls. The chamber will always have sides at x = 0, x = 10, y = 0, and y = 10. The initial and final points of the path are always (0, 5) and (10, 5). There will also be from 0 to 18 vertical walls inside the chamber, each with two doorways. The figure below illustrates such a chamber and also shows the path of minimal length.

Input

The input data for the illustrated chamber would appear as follows.

2
4 2 7 8 9
7 3 4.5 6 7

The first line contains the number of interior walls. Then there is a line for each such wall, containing five real numbers. The first number is the x coordinate of the wall (0 < x < 10), and the remaining four are the y coordinates of the ends of the doorways in that wall. The x coordinates of the walls are in increasing order, and within each line the y coordinates are in increasing order. The input will contain at least one such set of data. The end of the data comes when the number of walls is -1.

Output

The output should contain one line of output for each chamber. The line should contain the minimal path length rounded to two decimal places past the decimal point, and always showing the two decimal places past the decimal point. The line should contain no blanks.

Sample Input

1
5 4 6 7 8
2
4 2 7 8 9
7 3 4.5 6 7
-1

Sample Output

10.00
10.06


Source: Mid-Central USA 1996

交题的时候poj挂了,在hdu上也没找到,突然想起自己学校的oj,在toj上一找还真找到了,交了一发,1A,开心~

说明toj还是很厉害的,题目还是很全的~

思路:乍一看感觉是一道几何题,再一看发现可以用最短路做

在所有点之间连线,判断跟墙是否相交,不相交的话就建边,然后跑一边最短路,什么方法都行了

#include <iostream>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>

#define INF 100000000.0

using namespace std;

struct point
{
    double x,y;
    point(){};
    point (double _x,double _y)
    {
        x=_x,y=_y;
    }
};
typedef point vec;

double operator /(vec a, vec b)
{
    return (a.x*b.y-a.y*b.x);
}
vec operator- (point a,point b)
{
    vec c;
    c.x=a.x-b.x;
    c.y=a.y-b.y;
    return c;
}
struct line
{
    point a,b;
    line(){};
    line (point _a,point _b)
    {
        a=_a;
        b=_b;
    }
};
double dis(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

struct edge
{
    int v,next;
    double w;
};
int cross(line m,line n)
{
    if(((n.a-m.a)/(m.b-m.a))*((n.b-m.a)/(m.b-m.a))<=0
       &&((m.a-n.a)/(n.b-n.a))*((m.b-n.a)/(n.b-n.a))<=0)
       return 1;
       else return 0;
}
edge e[5005];
int head[105],cnt=0,vis[5005],n,m;
double dist[105];
queue<int>q;
void addedge(int u,int v,double w)
{
    e[cnt].v=v;
    e[cnt].w=w;
    e[cnt].next=head[u];
    head[u]=cnt++;
}
void init()
{
    memset(head,-1,sizeof(head));
    cnt=0;
}
void spfa(int s)
{
    for(int i=0;i<=n;i++)
        dist[i]=INF,vis[i]=0;
    while(!q.empty()) q.pop();
    q.push(s);
    vis[s]=1;
    dist[s]=0.0;
    while(!q.empty())
    {
        int tmp;
        tmp=q.front();
        q.pop();
        for(int i=head[tmp];i!=-1;i=e[i].next)
        {
            if(dist[e[i].v]>dist[tmp]+e[i].w)
            {
                dist[e[i].v]=dist[tmp]+e[i].w;
                if(!vis[e[i].v])
                {
                    vis[e[i].v]=1;
                    q.push(e[i].v);
                }
            }

        }
        vis[tmp]=0;
    }
}
point p[105];
line le[5005];
bool check(int i,int j)
{
    line temp(p[i],p[j]);
    int left,right;
    if(i!=0 && j!=n-1)
    {
        left=(((i-1)/4)+1)*3;
        right=((j-1)/4)*3;
        for(int c1=left;c1<right;c1++)
        {
            if(cross(temp,le[c1]))
            {
                return false;
            }
        }
    }
    else if(i==0 && j!=n-1)
    {
        right=((j-1)/4)*3;
        for(int c1=0;c1<right;c1++)
        {
            if(cross(temp,le[c1]))
            {
                return false;
            }
        }
    }
    else if(i!=0 && j==n-1)
    {
        left=(((i-1)/4)+1)*3;
        for(int c1=left;c1<m-1;c1++)
        {
            if(cross(temp,le[c1]))
            {
                return false;
            }
        }
    }
    else
    {
        for(int c1=0;c1<m-1;c1++)
        {
            if(cross(temp,le[c1]))
            {
                return false;
            }
        }
    }
    return true;
}
int main()
{
    int t;
    while(cin>>t)
    {
        if(t==-1)
            break;
        init();
        int totl=0,totp=1;
        n=4*t+2;
        m=3*t;
        p[0].x=0,p[0].y=5.0;
        p[n-1].x=10.0,p[n-1].y=5.0;
        for(int i=0;i<t;i++)
        {
            double x,y1,y2,y3,y4;
            point a,b;
            line tmp;
            cin>>x>>y1>>y2>>y3>>y4;
            p[totp].x=x,p[totp++].y=y1;
            p[totp].x=x,p[totp++].y=y2;
            p[totp].x=x,p[totp++].y=y3;
            p[totp].x=x,p[totp++].y=y4;
            a.x=x,a.y=0.0;
            b.x=x,b.y=y1;
            tmp.a=a,tmp.b=b;
            le[totl++]=tmp;
            a.x=x,a.y=y2;
            b.x=x,b.y=y3;
            tmp.a=a,tmp.b=b;
            le[totl++]=tmp;
            a.x=x,a.y=y4;
            b.x=x,b.y=10.0;
            tmp.a=a,tmp.b=b;
            le[totl++]=tmp;
        }
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(check(i,j))
                    addedge(i,j,dis(p[i],p[j]));
            }
        }
        spfa(0);
        double ans=dist[n-1];
        cout<<fixed<<setprecision(2)<<ans<<endl;
    }
    return 0;
}


基于TROPOMI高光谱遥感仪器获取的大气成分观测资料,本研究聚焦于大气污染物一氧化氮(NO₂)的空间分布与浓度定量反演问题。NO₂作为影响空气质量的关键指标,其精确监测对环境保护与大气科学研究具有显著价值。当前,利用卫星遥感数据结合先进算法实现NO₂浓度的高精度反演已成为该领域的重要研究方向。 本研究构建了一套以深度学习为核心的技术框架,整合了来自TROPOMI仪器的光谱辐射信息、观测几何参数以及辅助气象数据,形成多维度特征数据集。该数据集充分融合了不同来源的观测信息,为深入解析大气中NO₂的时空变化规律提供了数据基础,有助于提升反演模型的准确性与环境预测的可靠性。 在模型架构方面,项目设计了一种多分支神经网络,用于分别处理光谱特征与气象特征等多模态数据。各分支通过独立学习提取代表性特征,并在深层网络中进行特征融合,从而综合利用不同数据的互补信息,显著提高了NO₂浓度反演的整体精度。这种多源信息融合策略有效增强了模型对复杂大气环境的表征能力。 研究过程涵盖了系统的数据处理流程。前期预处理包括辐射定标、噪声抑制及数据标准化等步骤,以保障输入特征的质量与一致性;后期处理则涉及模型输出的物理量转换与结果验证,确保反演结果符合实际大气浓度范围,提升数据的实用价值。 此外,本研究进一步对不同功能区域(如城市建成区、工业带、郊区及自然背景区)的NO₂浓度分布进行了对比分析,揭示了人类活动与污染物空间格局的关联性。相关结论可为区域环境规划、污染管控政策的制定提供科学依据,助力大气环境治理与公共健康保护。 综上所述,本研究通过融合TROPOMI高光谱数据与多模态特征深度学习技术,发展了一套高效、准确的大气NO₂浓度遥感反演方法,不仅提升了卫星大气监测的技术水平,也为环境管理与决策支持提供了重要的技术工具。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值