Lift Hopping

Lift Hopping, UVa 10801【Floyd】 #include #include #include #include #include #include using namespace std; int n,k; int v[10]; vector can[10]; int dis[110][110]; #define INF 1e9 int main(void) { int tmp; while(scanf("%d%d",&n,&k)= 阅读详情

Ted the bellhop: “I’m coming up and if there isn’t
a dead body by the time I get there, I’ll make one
myself. You!”
Robert Rodriguez, “Four Rooms.”
A skyscraper has no more than 100 floors, numbered from 0 to 99. It has n (1 ≤ n ≤ 5) elevators
which travel up and down at (possibly) different speeds. For each i in {1, 2, … n}, elevator number
i takes Ti (1 ≤ Ti ≤ 100) seconds to travel between any two adjacent floors (going up or down).
Elevators do not necessarily stop at every floor. What’s worse, not every floor is necessarily accessible
by an elevator.
You are on floor 0 and would like to get to floor k as quickly as possible. Assume that you do not
need to wait to board the first elevator you step into and (for simplicity) the operation of switching an
elevator on some floor always takes exactly a minute. Of course, both elevators have to stop at that
floor. You are forbiden from using the staircase. No one else is in the elevator with you, so you don’t
have to stop if you don’t want to. Calculate the minimum number of seconds required to get from floor
0 to floor k (passing floor k while inside an elevator that does not stop there does not count as “getting
to floor k”).
Input
The input will consist of a number of test cases. Each test case will begin with two numbers, n and k,
on a line. The next line will contain the numbers T1, T2, … Tn.
Finally, the next n lines will contain sorted lists of integers – the first line will list the floors visited
by elevator number 1, the next one will list the floors visited by elevator number 2, etc.
Output
For each test case, output one number on a line by itself - the minimum number of seconds required to
get to floor k from floor 0. If it is impossible to do, print ‘IMPOSSIBLE’ instead.
Explanation of examples
In the first example, take elevator 1 to floor 13 (130 seconds), wait 60 seconds to switch to elevator
2 and ride it to floor 30 (85 seconds) for a total of 275 seconds.
In the second example, take elevator 1 to floor 10, switch to elevator 2 and ride it until floor 25.
There, switch back to elevator 1 and get off at the 30’th floor. The total time is 10 ∗ 10 + 60 + 15 ∗ 1 +
60 + 5 ∗ 10 = 285 seconds.
In example 3, take elevator 1 to floor 30, then elevator 2 to floor 20 and then elevator 3 to floor 50.
In the last example, the one elevator does not stop at floor 1.
Sample Input
2 30
10 5
0 1 3 5 7 9 11 13 15 20 99
4 13 15 19 20 25 30
2 30
10 1
0 5 10 12 14 20 25 30
2 4 6 8 10 12 14 22 25 28 29
3 50
10 50 100
0 10 30 40
0 20 30
0 20 50
1 1
2
0 2 4 6 8 10
一座大楼0到99层,最多有5个电梯,每个电梯有自己的速度,和自己独特的停靠楼层,换电梯需要额外的60s,问到达目标楼层的最短时间。
图实在是太明显了,直接100层而已,然后直接用迪杰斯特拉一个一个找。
一开始赋值表达式写了比较之前的电梯与之后电梯是否一致……后来发现根本不需要比较,因为如果之前就是这部电梯,那么到达的那个点一定在之前搜索过了,而且是不加60s的情况,所以就算表达式中加60s与之前比较,也会被过滤掉。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
struct Node{
    int v;
    int leap[105];
}node[10];
int vis[105], d[105];
int main()
{
    int i, j, m, n, ans, t, k;
    while (scanf("%d%d", &n, &k) != EOF)
    {
        for (i = 1; i <= n; i++)
        {
            cin >> node[i].v;
            for (j = 0; j <= 100; j++)
                node[i].leap[j] = 0;
        }
        int cnt = 1;
        while (cnt <= n)
        {
            int x;
            char c;
            c = 'a';
            while (c != '\n'){
                cin >> x;
                node[cnt].leap[x] = 1;
                c = getchar();
            }
            cnt++;
        }
        memset(vis, 0, sizeof(vis));
        for (i = 1; i <= 100; i++)
            d[i] = inf;
        d[0] = 0;
        vis[0] = 1;
        for (i = 1; i <= n; i++)
        {
            if (node[i].leap[0])
            {
                for (j = 1; j <= 100; j++)
                if (node[i].leap[j])
                {
                    d[j] = min(d[j], node[i].v*j);
                }
            }
        }
        for (i = 1; i <= 100; i++)
        {
            int tempx, tempm;
            tempx = tempm = inf;
            for (j = 1; j <= 100; j++)
            {
                if (!vis[j] && d[j] <= tempm)
                {
                    tempm = d[j];
                    tempx = j;
                }
            }
            if (tempx == inf)break;
            vis[tempx] = 1;
            for (j = 1; j <= 100; j++)
            {
                int k;
                for (k = 1; k <= n; k++)
                {
                    if (node[k].leap[j] && node[k].leap[tempx])
                    {
                        d[j] = min(d[j], d[tempx] + node[k].v*abs(tempx - j) + 60);
                    }
                }
            }
        }
        if (d[k] == inf)
            cout << "IMPOSSIBLE" << endl;
        else
            cout << d[k] << endl;
    }
    return 0;
}
2080Ti双卡开启NVLink 本文介绍了如何在Ubuntu 22.04系统下给2080Ti双卡开启NVLink的方法。 阅读详情

相关推荐

RADIOML 2018.01A数据集在自动调制识别中的实战应用指南

本文提供了RADIOML 2018.01A数据集在自动调制识别(AMR)任务中的完整实战指南。内容涵盖从数据集介绍、数据获取与解包、高效预处理流程,到构建PyTorch数据管道、模型设计(如1D CNN、ResNet)以及训练调参策略。重点阐述了如何利用该数据集训练鲁棒的AI模型,以应对复杂信道环境和低信噪比挑战,并给出了详细的性能评估方法。

plant的博客 171

Lift Hopping UVA - 10801

对于可以通过同一个电梯到达的楼层与楼层之间建边,边的权值为电梯的运动所需要花费的时间的值,然后从第0层开始使用迪杰斯特拉算法得出最终的结果,这里需要注意几个问题:边是双向的,也就是对应电梯既可以从下向上运动也可以从上向下运动,同时对于目标楼层为第0层的情况要进行特判,对于可达到的情况我们需要减去一个60,因为开始进入电梯的时候是不要转移的时间的,但是为了在代码中方便进行统一的处理,我们都加上了60

zju2016的博客 287

手把手教你用Siemens EDA破解工具搞定PADs VX2.7安装与卡死问题

本文详细介绍了如何使用Siemens EDA工具解决PADs VX2.7的安装与卡死问题。从License配置到性能调优,提供全面的解决方案,帮助工程师高效完成电子设计自动化任务。特别针对常见的卡顿现象,给出了输入法兼容性调整、图形性能优化等实用技巧。

k8l9m0n的博客 549

[UVA 10801]Lift Hopping[Dijkstra][建图]

题目链接:[UVA 10801]Lift Hopping[Dijkstra][建图] 题意分析: 从0层开始,一共有n台电梯供你到达目的地k层。每台电梯往上走一层都要消耗t[i]的时间,并且电梯只能在特定的楼层停下,换成电梯要花费60s的时间,而且呢,你不能用楼梯上楼,只能搭电梯。。。。(hentai!)问:最快到达楼层k的时间是多少?不能到达就输出-1。 解题思路: 这题技巧就是体现在建

闲停 983

Synology-群晖(三)DSM7.0系统Video Station无法播放DTS eac3解决方案

群晖升级DSM7.0后,发现部分DTS eac3解码的视频无法通过Vedio Station 3.0.1-2067进行播放,提示不支持该格式视频,初步判断是无法加载ffmpeg解码导致,网上搜了很多处理办法都没有办法解决,最终在知乎上看到一片文章,按此办法解决了这个问题,目前经过验证,该方案完美支持最新版本Video Station 3.0.1-2067,验证系统为DSM7.0和DSM7.0.1,这里使用的NAS为 Vmware虚拟机 黑群晖 演示。大概步骤如下: 添加这个社群来源 http://p

weixin_45827203的博客 3万+

PC微信逆向) 读取内存联系人链表

首先从一些网络上搜索到的信息可以得出联系人列表是保存在内存里的,并且是全局变量不会被释放,所以我们可以通过搜索某个联系人的信息来定位

Qwertyuiop2016的博客 2918

Lift Hopping UVA - 10801 (建图+Dijkstra)

传送门 题意:在一个大楼里,有编号为0~99的100层楼里,还有n座电梯,任务是从0楼到达第k楼,每个电梯都有一个运行速度,表示到达一个相邻楼层需要的时间,由于每个电梯不一定每层都停留,有时需要从一个电梯换到另一个电梯中。换电梯时间总是一分钟,前提两座电梯能停留在换乘楼层,大楼里只有你一个人,问最少需要的时间? 题解:对于电梯x来说,假如它在第i层停留,把x在i层的出口看作一个顶点记为x*10...

肘子的博客 294

AI视频生成成本优化实战:混合架构与硬件选型

AI视频生成技术正面临效果与成本的二元博弈,其核心挑战在于高昂的推理算力消耗与黑箱服务的不确定性。从技术原理看,视频生成依赖扩散模型等深度学习架构,通过多轮迭代实现像素级合成,这导致GPU显存占用和电力消耗呈指数级增长。在工程实践中,采用混合推理架构能有效平衡成本与质量,例如云端处理关键帧配合本地渲染过渡帧,实测可降低58%支出。硬件选型方面,消费级显卡魔改与边缘计算设备为中小企业提供了可行方案,如RTX 3090显存扩容或Jetson AGX边缘部署。当前AI视频应用已渗透电商直播、新闻制作等领域,但需警

weixin_29531177的博客 293

UVA 10801 Lift Hopping

算是一道需要动脑筋的最短路问题了,关键在于建图部分,对于n个电梯中每一个都要经过cnt个楼层,a[0],a[1],a[2],a[3],a[4],......a[cnt-1],那么对于任意两个楼层a[j],a[l],都需要建立一条a[j]到a[l]的边,以及另一条反向边。而且为了表示所属的电梯,另外用一个数组tag[e]表示边e所属的电梯,当tag[e1]!=tag[e2],应该在时间上加上60s。

rootial的专栏 444

claude-hub:GitHub上的AI开发助手,让Claude自动帮你写代码、审代码、合代码

代码不再是人写的,而是人引导 AI 写的。在这个时代,GitHub 不再只是一个代码托管平台,而是 AI 开发代理的工作台。每一个 issue、每一条 PR,都可能是一次与 AI 合作的机会。未来属于那些敢于把开发流程交给 AI 来优化的人——他们不是在取代自己,而是在放大自己的影响力。📌关注本系列文章,我们将持续输出关于 AI 编程、GitHub 自动化、AI Agent 产品化的深度分析。

这里汇聚了前沿的技术分享与实用的开发技巧,带你探索从创意到企业的技术创业之路。 1372

实战|mitmproxy+Playwright 拦截篡改Cloudflare验证流程,实现无感爬取(2026实测可用)

2026年对抗Cloudflare,别再死磕滑块、轨迹、算法。高伪装浏览器 + 中间层劫持篡改验证流程Playwright + mitmproxy = 无感过CF这篇是纯实战、无废话、可直接上线的方案。你只要把目标网站、cf_clearance填进去,就能跑通。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1284

最短路+uva10801

Lift Hopping Time Limit: 1 second Ted the bellhop: "I'm coming up and if there isn't a dead body by the time I get there, I'll make one myself. You!" Robert Rodriguez, "Four Rooms."

龙崎的专栏 843

光学传播仿真软件:SPEOS_(14).建筑物内光环境仿真

在建筑物内光环境仿真中,材料属性的定义直接影响光的传播和反射效果。SPEOS提供了丰富的材料库,但也可以自定义材料属性以满足特定需求。创建新材料选择Materials->。输入材料名称和类型。配置材料属性选择材料对象,打开属性编辑器。设置反射率、透射率、表面粗糙度和颜色。# 导入SPEOS模块# 创建新材料# 配置材料属性custom_material.set_reflectivity(0.8) # 设置反射率为0.8。

kkchenjj的博客 1245

UVa10801 - Lift Hopping

题意:一栋摩天楼(0~99层)有

A Cube Master 648

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

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

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

10801 - Lift Hopping

/*10801 - Lift Hopping * 以每一层楼为顶点,每个电梯可以到达的两层楼之间的秒数为每一条边的权值, * 以此构建一个无向图。然后利用dijkstra求出最短的时间, * 注意每次换乘电梯需要等待60s(注意初始定点不需要60s的等待)。*/ import java.util.Arrays; import java.util.Scanner; class Main {

annie11640389的专栏 545

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

uva 10801 Lift Hopping

UVA 10801 Lift Hopping

@fei 618

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

uva 10801 Lift Hopping(dijkstra)

uva 10801 Lift Hopping Ted the bellhop: "I'm coming up and if there isn't a dead body by the time I get there, I'll make one myself. You!" Robert Rodriguez, "Four Rooms."

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

UVA 10801 Lift Hopping

<br />题意:给n个电梯,电梯可在m个层停下,每个电梯的速度不一样,给出起点0,终点Goal,求从起点到终点花的最少时间。<br />这道题实际是求最短路的问题,也是隐式图的搜索,与658 - It's not a Bug, it's a Feature!是同一类问题。我们设从0层开始,先找出从0层所能到达的各个层(状态),放入队列,然后从队列中找出用时最少的状态继续进行找,直至找到Goal层,结束或队列空结束,算法思想类似dijkstra。<br />程序代码:<br />#include<iostr

七里的专栏 1363

uva 10801【Lift Hopping】

表示对这类题目没feel,抽象。。。参考别人的代码后写出来的,顺便练习了一下FIFO队列实现Bellman-ford算法。。。 代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 #include <cmath> 5 using n...

aoyuan4706的博客 101

uva_10801 Lift hopping

用Dijkstra即可,我用Floyd写的   #include #include #include #include #define N 100 const int inf = 10000000; using namespace std; typedef struct node{ int t, s, e; }; bool ele[5][N + 2]; n

Kizuki 574

uva 10801 - Lift Hopping

乘坐电梯 寻找最短时间的路线  即最短路问题  d[e.to]>d[u]+e.dist+60 最后输出的时候减去60 因为第一次换电梯不需要时间 // 需要注意的是k==0时 要进行特判 不然会输出-60、 #include #include #include #include #include #define maxn 100001 using namespace st

chenchaoflight的专栏 462

UVA 10801 Lift Hopping (最短路)

分析:题目规定了换乘的时间,所以这题就与根据时间的流逝没有关系的,变成了一个最短路问题,每个状态有两个属性,一个是所在电梯 i ,所在楼层 j ,以为本题的数据较小。可以用 i * 100 + j 来表示状态。然后就是求个最短路就行了 #include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #incl...

Insist_77的博客 333

UVaOJ 10801 - Lift Hopping

——by A Code Rabbit Description 一个很奇怪的地方有几个奇怪的电梯。 这些电梯的速度不同,并且不是每一层楼都可以到达的。 每个电梯都有自己可以到达的楼层。 并且你换乘电梯需要60s。 输入各种奇怪的数据。 输出你从0层到某一层的最短时间。 Type Graph Algorithms Analysis 把某个电梯到达某层抽象成

A Code Rabbit 1071

UVA 10801 - Lift Hopping Dijkstra 算法

d[i][j]表示从i电梯到j层所用的最短时间。 #include #include #include #include #include #include #include #define time ttt using namespace std; typedef struct node { int order,floor; node(int a=0,int b

anqier0468的专栏 785
上一篇: Say Cheese
下一篇: Sentry Robots
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值