POJ 1556 The Doors(判断线段相交 && 最短路)

单细胞实战之数据净化三部曲:细胞周期校正、双胞体剔除与RNA污染清理——技术解析与实战指南 本文深入解析单细胞数据分析中至关重要的数据净化步骤,即细胞周期校正、双胞体剔除与RNA污染清理。通过实战代码演示与原理剖析,指导读者如何有效识别并去除技术噪音,从而获得更纯净、可靠的数据,为后续的细胞分群、差异表达等高级分析奠定坚实基础。 阅读详情

The Doors

Description

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 file 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

【思路分析】

   这个题目有意思之处在于将计算几何和图论的问题巧妙地结合起来。题意大概是在一个图中给你4 * n + 1个点,其中有一个起点,一个终点以及每一列的四个点,每一列的四个点又构成了三个线段,即隔墙,要求起点到终点的最短路径(当然该路径不能“穿墙”)。该题最关键的就是建图,通过判断两点之间构成的路径是否和隔墙相交来在邻接矩阵中键入权值(即两点之间的路径),要注意的是这里的线段相交要忽视两线段有一个公共端点的情况,即考虑“擦墙而过”,所以两线段不相交时在邻接矩阵中相应位置键入两点之间的距离,若两线段相交则表示此路不通,键入一个无穷大值。当建图好之后就是找最短路了。


代码如下:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define eps 1e-8
#define inf 1e20
#define maxn 150
double maps[maxn][maxn];
double dis[maxn],visited[maxn];
int n;
struct Point
{
    double x,y;
    Point()
    {

    }
    Point(double x1,double y1)
    {
        x = x1;
        y = y1;
    }
    Point operator - (const Point &b) const
    {
        return Point(x - b.x,y - b.y);
    }
    double operator ^ (const Point &b) const
    {
        return x * b.y - y * b.x;
    }
    double operator * (const Point &b) const
    {
        return x * b.x + y * b.y;
    }
}points[maxn];
struct Line
{
    Point s,e;
    Line()
    {

    }
    Line(Point s1,Point e1)
    {
        s = s1;
        e = e1;
    }
}lines[maxn];
int sgn(double x)
{
    if(fabs(x) < eps)
        return 0;
    if(x < 0)
        return -1;
    return 1;
}
double distances(Point p1,Point p2)
{
    return sqrt((p2 - p1) * (p2 - p1));
}
bool intersection(Line l1,Line l2)
{
    return
    max(l1.s.x,l1.e.x) >= min(l2.s.x,l2.e.x) &&
    max(l1.s.y,l1.e.y) >= min(l2.s.y,l2.e.y) &&
    max(l2.s.x,l2.e.x) >= min(l1.s.x,l1.e.x) &&
    max(l2.s.y,l2.e.y) >= min(l1.s.y,l1.e.y) &&
    sgn((l2.s - l1.e) ^ (l1.s - l1.e)) * sgn((l2.e - l1.e) ^ (l1.s - l1.e)) < 0 &&
    sgn((l1.s - l2.e) ^ (l2.s - l2.e)) * sgn((l1.e - l2.e) ^ (l2.s - l2.e)) < 0;
    //注意此处是小于0,即忽视两个线段有一个公共端点的相交情况!
}
void init()
{
    points[0] = Point(0,5);
    for(int i = 1;i <= n;i++)
    {
        double x;
        scanf("%lf %lf %lf %lf %lf",&x,&points[i].y,&points[i + n].y,&points[i + n * 2].y,&points[i + n * 3].y);
        points[i].x = points[i + n].x = points[i + n * 2].x = points[i + n * 3].x = x;
        lines[i] = Line(Point(x,0),points[i]);
        lines[i + n] = Line(points[i + n],points[i + n * 2]);
        lines[i + n * 2] = Line(points[i + n * 3],Point(x,10));
    }
    points[n * 4 + 1] = Point(10,5);
    bool flag = true;
    for(int i = 0;i <= n * 4 + 1;i++)//起点、终点加上每一列的4个点
    {
        for(int j = 0;j <= n * 4 + 1;j++)
        {
            flag = true;
            for(int k = 1;k <= 3 * n;k++)//每列三条线段
            {
                if(intersection(Line(points[i],points[j]),lines[k]))
                {
                    flag = false;
                    break;
                }
            }
            if(flag == true)//两线段不相交
            {
                maps[i][j] = distances(points[i],points[j]);
            }
            else
            {
                maps[i][j] = inf;
            }

        }
    }
}
double dijkstra(int s,int t)
{
    for(int i = 0;i <= n * 4 + 1;i++)
    {
        dis[i] = maps[s][i];
        visited[i] = 0;
    }
    dis[s] = 0;
    visited[s] = 1;
    int temp,k = s;
    for(int i = 1;i <= n * 4 + 1;i++)
    {
        temp = inf;
        for(int j = 0;j <= n * 4 + 1;j++)
        {
            if(visited[j] == 0 && temp > dis[j])
            {
                k = j;
                temp = dis[j];
            }
        }
        if(temp == inf)
            break;
        visited[k] = 1;
        for(int j = 0;j <= n * 4 + 1;j++)
        {
            if(dis[j] > dis[k] + maps[k][j])
                dis[j] = dis[k] + maps[k][j];
        }
    }
    return dis[t];
}
int main()
{
    while(scanf("%d",&n) != EOF && n != -1)
    {
        init();
        printf("%.2lf\n",dijkstra(0,n * 4 + 1));
    }
    return 0;
}


配置某VLAN下ONU的二层互访(隔离)问题(解决OLT二层隔离问题) 问题:OLT的ONU节点之间在同一VLAN下的终端默认隔离,在确实需要互通的场景下如何解决。 阅读详情

相关推荐

java调用第三方api接口获取数据

弊端,但是并不是每个接口都适用于这套模板,之前写的接口不适用,都是在这个模板里做了定制处理(if 特殊表 -》处理),需要考虑兼容之前的代码,这种兼容代码,有风险会改掉之前的逻辑个人喜欢,有一个接口,写一段代码灵活自由些。2.还有一部分是对post请求的返回数据,做处理,因为json返回的格式如果双方没有约定好,里面数据是多层json嵌套,需要做处理。江同事交接的就是这个代码模板,可以看下源码调试一下,之前交接的视频,也可以看下,主要还是看代码理解快些,将 写好的代码达成jar包,上传到linux上去,

随风不随水的博客 2043

计算几何——The Doors(Dijkstra和线段相交)

原文链接:http://poj.org/problem?id=1556 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 =...

mumei的博客 346

广工计组f4b 8位12指令微程序CPU设计实验报告(内含可通过代码以及波形图)

实验目的:模型机是计算机的缩细模型,通过它可以理解计算机整机的结构和功能,理解CPU,存储器,中断控制器,接口的结构及实现逻辑和各部件之前的接口关系。本实验是设计一个8位模型计算机。:一条机器指令可以分解成一个微操作序列,这些微操作是计算机最基本的,不可再细分的操作。:在微程序控制的计算机中。将控制部件向执行部件发出的各种控制命令成为微命令,它是构成控制序列的最小单位。微命令和微操作是一一对应的。微命令是微操作的控制信号,微操作微命令的执行过程。2.:微指令是若干微命令的集合。

weixin_63692154的博客 4714

poj1556 The Doors (计算几何+最短路)

The Doors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11497 Accepted: 4227 Description You are to find the length of the shortest path through a chamber containing obstructing walls. ...

八百标兵奔北坡的博客 305

RK3588S Andriod12调试OLED屏幕背光

4,kernel-5.10/drivers/gpu/drm/drm_mipi_dsi.c中mipi_dsi_dcs_set_display_brightness函数就是调节亮度的地方。这一步很重要,因为上层调节背光时就是操作的这个背光设备节点(/sys/class/backlight/backlight),如果名字不对,上层调用的通路就没有打通。之后在dcs_bl_update_status函数中做个映射,通过调整brightness_table中的值就可以对背光亮度的调节曲线作出调整。

u011774634的博客 4446

视觉语言模型对抗攻击与防御:从传统方法到多模态挑战

本文深入探讨了视觉语言模型(VLM)面临的对抗攻击与防御挑战,从传统单模态攻击到多模态威胁的演进。分析了包括FGSM、PGD等经典攻击方法,以及新兴的多模态攻击如跨模态对抗样本和越狱攻击。同时提出了跨模态一致性检查、动态防御机制等创新防御策略,并结合医疗影像诊断等实战案例,为提升AI系统安全性提供了重要见解。

weixin_29231725的博客 401

POJ-1556 判断相交+dijkstra

Description 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 fina...

刷题记录 202

Quartus (Quartus Prime 18.1)的安装及仿真步骤

前两天做计组的课设需要用到Quartus 这个软件,但安装有点麻烦,在网上搜了很多教程,发现都是旧版本的,最后弄了好半天才把环境搭建好。所以,分享一下它的搭建过程。 因为我不经常用它,所以安装的版本是精简版的其他版本的也应该差不多以下是需要下载的安装包: 准备: Quartus Prime 精简版,最新发布: v18.1 1. QuartusLiteSetup-18.1.0.625-wi...

weixin_41082948的博客 8万+

Closest Pair of Segments HDU - 6697

参考了大佬的题解 https://www.cnblogs.com/dd-bond/p/11391771.html 直接剪枝 #include <iostream> #include <cmath> #include <algorithm> using namespace std; const double eps=1e-8; const double...

leekerian的博客 358

OpenAI Error: 403 Country, region, or territory not supported [Python]

从OpenAI的API服务中获取数据时,由于你所在的国家、地区或领土不被支持,因此请求被拒绝了

suiusoar 5720

基于深度学习的心律失常的自动分类

基于深度学习的心律失常的自动分类 作者:禅与计算机程序设计艺术 1. 背景介绍 1.1 心律失常的危害与检测的重要性 心律失常是一种常见的心血管疾病,严重威胁着人们的健康和生命。据统计,全球每年有数百万人因心律失

AI架构师小马 1158

【跨立实验-非严格相交】poj1556

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 ...

SummerDream 271

LeRobot 入门教程(十三)集成自定义的机器人、相机等硬件

本文详细介绍了如何将自定义机器人集成到LeRobot生态系统的完整流程。主要内容包括:1)硬件准备与通信接口选择;2)继承Robot基类实现标准接口;3)定义观察特征和动作特征;4)处理设备连接/断开逻辑;5)支持校准与配置;6)实现核心传感器读取和动作发送功能;7)可选遥操作器集成;8)遵循4项规范打包自定义设备(命名前缀、类名对应、文件结构、模块暴露);9)提供了完整实现示例。通过该方案,开发者可让自定义机器人兼容LeRobot的数据采集、控制管道和策略训练等全套工具链。

2506_90492529的博客 1914

POJ 1556 The Doors

POJ 1556 The Doors Description 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. T...

旺崽的博客 2919

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ 1556 The Doors (判断线段相交+dijkstra)

The Doors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7392   Accepted: 2900 Description You are to find the length of the shortest path through a chamber c

滴水穿石,慢慢积累,总会有成果 580

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【解题报告】 POJ 1556 The Doors -- 最短路问题 Dijkstra算法 + 直线相交

题目连接:POJ 1556 题目大意:从房间的坐标(0,5) -> (10,5),中间经过最多不超过18个墙,求路径最短。 这道题在nyoj上AC不了,貌似数据中墙会重复输入 ( waiting... ) // POJ 1556 The Doors -- 最短路问题 Dijkstra算法 + 直线相交 // PS : 自我感觉Dijkstra算法类似于 BFS // /*test data

生命有一种绝对 822

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

POJ_1556_The Doors_判断线段相交+最短路

POJ_1556_The Doors_判断线段相交+最短路 Description 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 ...

170

POJ - 1556 The Doors

http://poj.org/problem?id=1556 几何+最短路 先算出所有的n*4+2个点和3*n个边界,然后每次从n*4+2个点中取两个点,判断一下这两个点构成的线段是否与3*n个边界相交,如果不相交,那么表示“这条路”是可以走的,就加边,否则不加边,然后跑一遍最短路。 poj输出要%f,%lf 会错。 #include <iostream> #includ...

JZK-Keven 的博客 441

POJ - 1556 The Doors(线段相交+最短路)

题目链接:点击查看 题目大意:给出一个房间,房间内有许多墙壁(最多18堵墙),现在要从(0,5)点到(10,5)点,问最短路程是多少 题目分析:若要使路程最短,肯定要在两点之间前进,这样我们可以在建好墙后,根据线段相交问题渐变,判断两个点之间是否有线段挡着,如果没有挡着,直接建边,边权为两点的直线距离,如果被挡着了,也就是存在一条线段和当前线段规范相交,则说明两点无法直接到达,则边权置为无穷大...

Falcon的博客 415

POJ 1556 The Doors 点与线段交+最短路

题目链接:http://poj.org/problem?id=1556 题目大意:一个房间里有很多墙,每道墙上有两个门,求从房间左边中点到右边中点的最短距离。如图:   这道题目说起来就是一道最短路的题,但是两点之间是否能够走,需要判断一下两点之间的连线是不是跟墙有交点,就是计算几何的判断线段相交问题。两类典型的题合在一起了。 由于数据范围小的可怜,无脑暴力+floyd都能

foreyes_1001的博客 461

【POJ 1556】The Doors

1.题目链接。首先这个题目的输入有点迷,为了把问题描述清楚也是不容易。然后就是POJ的小数问题,输出采用%.2f,%.2lf依然是错的。 2.具体的做法就是把每个点拿出来,然后跑最短路。我们需要判断线段之间是不是相交,这中间可以采用一个小技巧,我们把每一堵墙中间的空隙拿出来存着,然后对于每一条路判断是不是与这些空隙相交,如果相交,说明这条路是可用的,否则不可用。这样看来其实spfa是很合适来求这...

YG爱木木 264

POJ 1556(The Doors )计算几何(线段相交)+最短路

题意: 要求的是在一个空间内有许多墙,每个墙上有两扇门你要从最左边中点去最右边中点的最短路。 思路: 把每扇门看作是两个点然后利用计算几何的知识来判断一下两个点所形成的线段与图中的墙(也就是线段)有没有相交,规范相交与重合才算相交,对于不相交的两个点之间建立边,然后跑最短路就可以了。 细节请见代码注释。 #include<iostream> #include<cstdio>...

laaahu的博客 516

The Doors POJ1556 线段相交 最短路

题目链接 解法:暴力判断任意两点是否可直达,并求出距离 处理完后用floyd算法求任意两点最短路 输出dis[0][4*n+1]即可 #include <map> #include <set> #include <cmath> #include <queue> #include <cstdio> #include ...

郭源潮 205

POJ 1556 The Doors【单源最短+线段相交】

点击打开链接 题意: 给你一个10*10的方格, 然后在里面放不超过十堵墙。然后问你从 (0,5)->(10,5)的最短路。 题解: 最短路,但是建图非常恶心,需要判断线段之间是否相交。不相交才能建边。 判断两线段是否相交。模板 double mult(Point a, Point b, Point c) { return (a.x-

zoro_n的博客 368

poj-1556-The Doors-dij+线段相交

计算几何:求两条线段是否相交。 求两条线段是否相交只需要求两条线段的两个短点是否都在另外一条线段的两侧即可。 图论:dij求最短路 #include #include #include #include #include using namespace std; #define maxn 200000 #define eps 0.00001 #define zero(x) ((fabs(x)

青竹梦 1245

POJ 1556 The Doors(判断线段相交+最短路)

题目链接 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 point...

Happig的博客 240
上一篇: ZOJ 3778 Talented Chef
下一篇: FZU 2197 最小花费
Spectacules
博客等级 码龄12年 2粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值