Adventure of Super Mario UVA10269(floyd+dijstkra+动态规划)

最短路径问题---Dijkstra算法详解 前言 Nobody can go back and start a new beginning,but anyone can start today and make a new ending. Name:Willam Time:2017/3/8 1、最短路径问题介绍 问题解释: 从图中的某个顶点出发到达另外一个顶点的所经过的边的权重和最小的一条路径,称为最短路径 解决问题的算法:... 阅读详情

题目大意就是:马里奥有个可以用K次的魔法鞋,然后每次魔法鞋可以穿过不超过L米,并且不可以穿过城堡,问最短时间。


思路:用dp[i][j]表示,到第i个点,还剩j次魔法鞋使用机会的最小时间。


这里预处理是用Floyd做的,floyd的本质就是枚举一个中间点,然后再枚举两边,所以只要中间这个k是城堡就直接跳过,不是的话就跑floyd。

#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
using namespace std;
const int maxn=120;
struct node
{
    int to;
    int w;
    int rem;
    bool operator < (node tar) const
    {
        if(tar.w>w) return true;
        return false;
    }
};

int fly[maxn][maxn];
vector<node> G[maxn];
int dis[maxn][12];
int A,B,M,L,K;

void init()
{
    memset(fly,0x3f,sizeof(fly));
    memset(dis,0x3f,sizeof(dis));
    for(int i=0;i<maxn;i++) G[i].clear();
}

void floyd()
{
    int ns=A+B;
    for(int k=1;k<=ns;k++)
    {
        if(k>=A+1) continue;//???????
        for(int i=1;i<=ns;i++)
        {
            for(int j=1;j<=ns;j++)
            {
                fly[i][j]=min(fly[i][j],fly[i][k]+fly[k][j]);
            }
        }
    }
}

void Dijstrka()
{

    memset(dis,0x3f,sizeof(dis));
    dis[A+B][K]=0;

    node temp;
    temp.to=A+B;
    temp.w=0;
    temp.rem=K;

    priority_queue<node> PQ;
    PQ.push(temp);
    while(PQ.empty()==false)
    {
        int now=PQ.top().to;
        int rem=PQ.top().rem;
        int sw=PQ.top().w;
        PQ.pop();
        int size=G[now].size();
        for(int j=0;j<size;j++)
        {
            int to=G[now][j].to;
            int w=G[now][j].w;
            if(dis[to][rem]>dis[now][rem]+w)
            {
                dis[to][rem]=dis[now][rem]+w;

                node newone;
                newone.w=dis[to][rem];
                newone.rem=rem;
                newone.to=to;
                PQ.push(newone);
            }
        }

        if(rem<1) continue;
        //??????
        for(int j=1;j<=A+B;j++)
        {
            if(fly[now][j]>L) continue;//???
            if(dis[j][rem-1]>sw)
            {
                dis[j][rem-1]=sw;

                node newone;
                newone.w=sw;
                newone.to=j;
                newone.rem=rem-1;
                PQ.push(newone);
            }
        }
    }
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        init();
        cin>>A>>B>>M>>L>>K;
        for(int i=0;i<M;i++)
        {
            int a,b,w;
            scanf("%d %d %d",&a,&b,&w);
            fly[a][b]=fly[b][a]=min(fly[a][b],w);
            node temp;
            temp.to=b;
            temp.w=w;
            G[a].push_back(temp);
            temp.to=a;
            G[b].push_back(temp);
        }

        floyd();
        Dijstrka();
        int ans=0x3f3f3f3f;
        for(int i=K;i>=0;i--)
        {
            ans=min(ans,dis[1][i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Dijkstra算法(迪杰斯特拉算法)详解 Dijkstra算法(迪杰斯特拉算法)可以在给定网(带权图)中查找一个顶点到其它顶点的最短路径,算法的时间复杂度为O(n2)。如果需要查找网中任意两个顶点之间的最短路径,虽然Dijkstra算法也能解决(对每个顶点都执行一次Dijkstra算法),但更建议使用Floyd弗洛伊德算法。当前阅读的是整套数据结构和算法教程中的一节内容,想系统学习数据结构和算法的读者,可以前往教程目录页面系统的学习,加我 q(834937624)获取教程的完整 PDF 电子版。 阅读详情

相关推荐

OAI骨关节炎数据集申请与DICOM下载全流程避坑指南

医学影像分析中,DICOM格式是存储与交换CT、MRI等数据的通用标准,其元数据Tag承载着像素间距、层厚等关键物理信息,直接影响定量分析的准确性。在骨关节炎研究领域,OAI数据集因样本量大、随访时间长而成为高价值资源,但获取需通过NDA协议申请,并借助nda-tools命令行工具完成TB级影像的批量下载与断点续传。这一流程涉及浏览器环境配置、DICOM格式转换及Python预处理等工程环节,任一细节疏漏都可能导致数据读取异常或分析偏差。掌握从申请到落地的完整链路,能显著提升医学影像AI研究的效率与可复现性

weixin_30843121的博客 276

最短路之dijsktra算法

Dijksatr算法是典型最短路算法,用于计算一个节点到其他所有节点的最短路径,主要特点是以起始点为中心向外层层扩展,直到拓展到终点为止。 那么dijkstra算法有什么特点呢? (1):单源最短路径算法,时间复杂度:O(n^2) (2)有向无向图都可以 (3)边的权值不能为负数 设G=(V,E)是一个带权有向图,把图中顶点集合V分成两组,第一组为已求出最短路径的顶点集合(用S表示,初始...

AC_AC_的博客 512

利用GeoTools高效切割GeoTIFF为WebP瓦片:从配置到实战

本文详细介绍了如何利用GeoTools将GeoTIFF高效切割为WebP瓦片,从环境配置到实战技巧全面覆盖。通过对比WebP与PNG格式的优势,展示其在体积压缩和传输效率上的显著提升,并提供多线程切割、内存管理等性能优化方案,帮助开发者快速实现地理空间数据的Web地图服务部署。

agile9scrum的博客 815

最短路径——Dijkstra算法和Floyd算法

一、最短路径概念        图中一个顶点到另一个顶点可能存在多条路径,每条路径所经过边的数量可能不同,每条路径所经过边的权值也可能不同,我们把花费最小的路径成为两个顶点的最短路径。        最短路径相关的两种常用算法:迪克斯特拉(Dijstra)算法和弗洛伊德(Floyd)算法。Dijstra算法用于快速求得图中一个顶点到其他所有顶点的最短距离和路径,Floyd算法用于求图中每对顶点的最...

每一次的失败都是踏上最终成功的垫脚石~ 3278

STM32F103 实例应用(10)——I2C读写24C32

一、应用简介 本文介绍24C32的读写,基于野火的软件I2C程序。 board_i2c.h /**=========================================================================== @file board_i2c.h @brief 本文件是用于I2C驱动 @author 青梅煮久 @version r0.1 @date 2021/01/13 -------------------------.

qq_34118600的博客 3447

【移动APP测试】Firebase Test Lab (FTL) 实战指南:从零搭建自动化测试流水线

本文详细介绍了Firebase Test Lab (FTL) 在移动APP测试中的实战应用,从零搭建自动化测试流水线。通过真实设备、虚拟设备和iOS设备的全面覆盖,FTL帮助开发者高效进行兼容性测试、性能监控和崩溃分析,显著提升应用质量。文章还提供了设备选择策略、成本控制技巧和CI/CD集成的最佳实践,助力团队优化测试流程。

weixin_29281915的博客 254

Dijstkra算法

文章目录问题描述输入格式输出格式输入样例输出样例解题思路思路优化测试代码 问题描述   在一幅图中有NNN个顶点和MMM条连接任意两点的边,每条边都是有向带权的且权值非负。求从一点出发到各点的最短路径长度及最短路径。 输入格式 & 输出格式 输入样例 6 8 0 0 1 1 0 3 4 0 4 4 1 3 2 2 5 1 3 2 2 3 4 3 4 5 3 输出样例 0 1 5 3 4 6...

A_fearless_engineer的博客 1124

智能体评测技术与实践:从评估维度到DeepEval实战指南

智能体评测技术与实践:从评估维度到DeepEval实战指南 本文系统探讨了AI智能体的评测体系与实践方法。首先从四个关键维度构建评估框架:基础能力(意图理解、知识完整性)、复杂任务(多轮对话、动态工作流)、可靠性(幻觉抑制、安全合规)以及工具效率(参数填充、多工具协同)。其次分析了主流评测工具,包括xBench的动态双轨评估、DeepEval的全链路监控等解决方案。最后详细介绍了DeepEval的实战应用,涵盖环境配置、测试用例构建、指标配置及CI/CD集成,展示了如何通过代码化评估实现智能体质量的持续提升

Linda的自动化测试之旅 3420

Dijkstra算法图文详解

Dijkstra算法 Dijkstra算法算是贪心思想实现的,首先把起点到所有点的距离存下来找个最短的,然后松弛一次再找出最短的,所谓的松弛操作就是,遍历一遍看通过刚刚找到的距离最短的点作为中转站会不会更近,如果更近了就更新距离,这样把所有的点找遍之后就存下了起点到其他所有点的最短距离。 问题引入: 指定一个点(源点)到其余各个顶点的最短路径,也叫做“单源最短路径”。例如求下图中...

black_hole6的博客 37万+

Jetson-nano 编译实时内核并烧录

前言 之前一篇文章介绍了正常的烧录过程,使用的是默认内核,实际工作中需要对内核打补丁升级为实时内核,并对其重编译。 一、准备内容 官网大法好 官方内核下载链接 官方交叉编译器下载链接 官方文档 ubuntu主机一台 根据官网选择下载对应的文件, 1、L4TDriver Package (BSP) source jetson内核文件。 2、官方交叉编译器 因为我们不是在jetson上直接编译,而jetson是arm平台,所以要进行交叉编译。 二、使用步骤 1.解压 内核 tar -xjf public_s

ldl371122的博客 3288

选型不再靠感觉:一文看懂 SAP Event Mesh 与 SAP Integration Suite, advanced event mesh 的能力边界

本文对比分析了SAP Event Mesh与SAP Integration Suite, advanced event mesh的差异。SAP Event Mesh适合轻量级场景,主要用于SAP系统间异步通信,支持AMQP、MQTT等协议,消息大小限制为1MB。而advanced event mesh面向企业级事件网络,提供跨云/本地部署、事件治理、监控等高级功能,支持30MB消息和更大存储容量。选择时需考虑业务规模、实时性要求、治理需求等因素:单一SAP生态内扩展可选Event Mesh;跨区域、多云环境

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 133

算法之迪杰斯特拉(dijkstra)非常详细介绍

迪杰斯特拉(dijkstra)算法是单源最短路径问题的求解方法。单源最短路径就在给出一个固定网络,指定一个原点s,一个目标点e,求这两个点之间的最短路径。举个栗子来理解一下。 小明上学的时候,从家到学校的道路非常多,小明为了减少路上骑车的时间,因此,想找出一个最短的路径。他构造一个网络图,如下: 小明是一个很喜欢动脑筋的同学,他开始研究如何才能找出最优的路径呢? 1)所有的点到家的距离都进行初始化: 2)每次选择距离家最短的一个点,然后用这个点的距离更新其他相邻点到家的距离,如果比当前的点小,则更新节点

PRML_MAN的博客 8万+

阿里云 Docker 镜像加速收费后:这些免费替代方案值得收藏

阿里云Docker镜像加速服务收费后,国内开发者急需免费替代方案。本文推荐2025年仍可用的7个免费镜像源,包括轩辕镜像、DaoCloud、网易云等,并提供多源配置方案以提高稳定性。建议开发者在CI/CD环境中配置多个镜像源,避免构建失败。文章还提供了详细的配置步骤和使用建议,适合个人和团队开发者参考。

sg_knight的专栏 1931

uva 10269(最短路径)

题意: 题解: #include #include #include using namespace std; const int N = 150; const int INF = 0x3f3f3f3f; int f[N][N], g[N][N], vis[N][N]; int t, n, m, p, l, cnt; void spfa() { int st = n + m; qu

俯瞰风景 1529

深度学习工具包 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")

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

UVA10269 最短路

题意:给定A个村庄和B个城堡,村庄编号为1到A,城堡编号为A+1到A+B,求问点1到点A+B最短路。其中可以开挂k次,每次可以瞬移最大距离为L。但有一个限制条件,瞬移经过的路径只能包含村庄。 分析:先用floyd求出任意两点只经过村庄的最短路。然后用SPFA求出点1到点A+B的最短路。类似求解动规,定义 d[u][k] 表示 从起点到点u 使用k次魔法所花费的最短时间。 代码如

勇敢前进的ACMer 333

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

uva 10269 Adventure of Super Mario (floyd + dijkstra)

uva 10269 Adventure of Super Mario题目大意:有A个村庄,B座城堡,村庄编号从1~A, 城堡编号从A + 1 ~ A + B。马里奥住在1号村庄,公主被关在A + B号城堡。马里奥有一件宝物,可以让他瞬间跑过L的距离,但是这件宝物是有限制的。发动这件宝物的起点或终点必须是村庄或者城堡,并且不能穿过城堡。这样的宝物当然不能随便用,所以它的耐久度只有K,也就是最多只能有K

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 1038

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

uva10269_SPFA思想+DP转移

题目 题目大意:有n个村庄和m个城堡,编号从1到n+m,给出一个有权图,没有自环和重边。马里奥走一个单位距离需要一个单位时间。起点为城堡n+m,终点为乡村1。马里奥可以瞬移K次,每次瞬移不超过距离L,且起点和终点必须为村庄或城堡、到达一个城堡时必须结束当前瞬移。求到达村庄1的最小花费时间。 详见uva10269 解题思路 DP[i][j][k]DP[i][j][k]DP[i][j][k]表示到达城市iii,还剩jjj次瞬移机会,上次瞬移机会还剩下kkk单位距离可以使用。分类讨论,状态过多,具体看代码注释。

陈颜的博客 228

uva 10269 - Adventure of Super Mario(Floyd + Dijkstra + dp)

题目链接:uva 10269 - Adventure of Super Mario 题目大意:马里奥就出桃子之后,要返回自己所居住的村子标号为1,给出A 和 B表示有A个村子和B个城堡,大魔王所居住的城堡A + B,1 ~A为村子,A + 1 ~ B为城堡。现在有m条路,连接着村子、城堡;每条路有它的距离;然后马里奥可以使用k次魔法,可以从一个地方瞬间移动到另外一个地方(不可以在路中间停

不慌不忙、不急不躁 1937

【Uva 10269 马里奥与公主的归途】

·马里奥n次解救了公主,现在需要从魔王的宫殿返回。 ·英文题,述大意: 给定一个点数不超过100的无向图,其中的点分为两类:乡村和城堡。 输入A个乡村,B个城堡(乡村编号1~A,城堡编号A+1~B),并给出m条无向路径及其需要花费的时间。不过还输入了K,L,表示马里奥有一双可以使用K次的高级鞋子,使用一次可前往原本L时间内的所有地方(一瞬间)。不过有一个限制条件是若使用鞋子加速,不能...

weixin_34195142的博客 146

uva10269

题意: 1-n是村庄,n+1-m+1是城堡,要从1-n+m,问最短时间 思路: 首先要为使用魔法做准备,这就需要求得沿路不经过城堡的所有路径(保证在最短状态),这就用到了floyd,然后是用spfa求用到魔法的最小时间 f[i][j]表示剩余i次到达j用时 如果不使用魔法能的到更短时间就不使用魔法 如果使用了魔法,那么首先路径必须 代码: #include #include #in

deepquiet的博客 355

UVA 10269 - Adventure of Super Mario(最短路 + dp)

Problem A Adventure of Super Mario Input: Standard Input Output: Standard Output After rescuing the beautiful princess, Super Mario needs to find a way home -- with the princess of course :-

Remilia's 2434

uva10269(最短路)

#include #include #include using namespace std; const int N = 105; const int INF = 0x3f3f3f3f ; int d[N][N]; int g[N][N]; int p[N]; int vis[N][N]; int a,b,m,l,k; int spfa(int s) { queue q1; queue

潜水的程序猿 500

uva 10269 最短路+dp

题意:有a个村庄、b个城镇, 编号分别为:1—a , a+1——a+b 。 有双神奇的鞋,可以瞬时移动,可以使用k次,每次可以移动L , 但穿这双鞋的时候,不能经过城镇 , 问:从a+b 到 1 最短距离是多少? 刚开始看这个题时 , 一点思路都没有 , dp类型的题目做得太少了。 解法:进行状态压缩, 用点+使用鞋子的次数 , 来表示一个状态 , d[i][k] , 表示到

zengchenacmer的专栏 1250

最短路径算法——Dijkstra算法——python3实现

本文参考来自数据结构与算法分析 java语言描述。 问题描述 问题分析 实现过程 如何使用数据变化表 问题描述 现有一个有向赋权图。如下图所示: 问题:根据每条边的权值,求出从起点s到其他每个顶点的最短路径和最短路径的长度。 说明:不考虑权值为负的情况,否则会出现负值圈问题。 s:起点 v:算法当前分析处理的顶点 w:与v邻接的顶点 dvdvd_v:从s到v的距离 ...

anlian523的博客 6万+

UVA 10269 Adventure of Super Mario floyd dp

Problem A Adventure of Super Mario Input: Standard Input Output: Standard Output After rescuing the beautiful princess, Super Mario needs to find a way home -- with the princess of course

Azarath Metrion Zinthos 1255

Dijkstra算法的简单python实现

Dijkstra算法介绍: http://wiki.jikexueyuan.com/project/easy-learn-algorithm/dijkstra.html 按照Dijkstra算法的思路用python实现了一下,用邻接矩阵表示点与点之间边的权重。刚接触Dijkstra算法,网上python实现的程序太过复杂因此没看,如果程序有错误欢迎指出。 以下图为例: 他的邻接矩阵如下...

tangg555的博客 2万+
上一篇: POJ 1364 King (差分约束系统)
下一篇: Repeats SPOJ (后缀数组,寻找一个重复次数最多的子串)
getupdown
博客等级 码龄11年 1粉丝 48原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值