HDU 1548 A strange lift(最短路&&bfs)】的更多相关文章

A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26943    Accepted Submission(s): 9699 Problem Description There is a strange lift.The lift can stop can at every floor as you want,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548 There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if yo…
题目大意: 电梯有两个选项向上或向下,每层楼有一个参数ki,代表电梯可以再该楼层的基础上向上或向下移动ki层,限制条件是向上不能超过楼层总数n,向下不能少于一.输入总层数n和当前所在层数以及目标层数,然后是n个数分别代表第i层的移动范围.输出最少移动次数,若不可达,输出-1. 解题思路: 1.用Dijkstra算法,首先构建邻接矩阵,注意在构造时,要考虑i-k[i]<1和i+k[i]>n,i代表当前所在层. #include<string.h> #include<stdio.…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1548 A strange lift Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number $K_i(0 \leq K_i \leq N)$ on every floor.The lift have just two buttons: up…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548 A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21754    Accepted Submission(s): 7969 Problem Description There is a strange li…
题目链接: 传送门 A strange lift Time Limit: 1000MS     Memory Limit: 32768 K Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and…
A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8550    Accepted Submission(s): 3241 Problem Description There is a strange lift.The lift can stop can at every floor as you want,…
Problem Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP"…
A strange lift http://acm.hdu.edu.cn/showproblem.php?pid=1548 Problem Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and…
A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11341    Accepted Submission(s): 4289 Problem Description There is a strange lift.The lift can stop can at every floor as you want…
题目链接 Problem Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP…
A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33697    Accepted Submission(s): 12038 Problem Description There is a strange lift.The lift can stop can at every floor as you want…
A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18723    Accepted Submission(s): 6926 Problem Description There is a strange lift.The lift can stop can at every floor as you want,…
题意:给出一个电梯,给出它的层数f,给出起点s,终点g,以及在每一层能够上或者下w[i]层,问至少需要按多少次按钮到达终点. 和POJ catch that cow一样,直接用了那一题的代码,发现一直wa, 后来才发现,POJ catch that cow是单组输入的,所以每次调用的时候不用清空队列,而这一题一次输入有多组数据--- 用这个清空队列 while(!q.empty()) q.pop(); #include<iostream> #include<cstdio> #inc…
题意: 有一座电梯,其中楼层从1-n,每层都有一个数字k,当处于某一层时,只能往上走k层,或者下走k层.楼主在a层,问是否能到达第b层? 思路: 在起点时只能往上走和往下走两个选择,之后的每层都是这样,那么就类似于二叉树.每个节点就是对应的层,因为有可能碰到循环的层,比如1跳到3,3跳回1,这样使得无限循环,所以加个vis数组标记是否遍历过即可. #include <iostream> #include <cmath> #include <cstring> #inclu…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548 题目意思:给出 n 个 floor 你,每个floor 有一个数k,按下它可以到达 floor + k 或者 floor - k的位置.问从floor A 到 floor  B 最少的按lift 次数是多少. hdu 真是!!!!! queue<node>  q 写在main 外就 wa了!!! = = 汗!!! 还专门瞪大双眼对照别人AC的代码,看了一遍又一遍,以为色盲了= =,可恶HDU…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548 题目大意:升降电梯,先给出n层楼,然后给出起始的位置,即使输出从A楼道B楼的最短时间. 注意的几点 (1)每次按一下,只能表示上或者是下,然后根据输入的看是上几层或者是下几层. (2)注意不能到底不存在的楼层. 详见代码. #include <iostream> #include <cstdio> using namespace std; ; ][],node[],vis[],M…
https://vjudge.net/problem/HDU-1548 题意: 电梯每层有一个不同的数字,例如第n层有个数字k,那么这一层只能上k层或下k层,但是不能低于一层或高于n层,给定起点与终点,要求出最少要按几次键. 思路: 可以用BFS,也可以用迪杰斯特拉算法. #include<iostream> #include<cstring> #include<algorithm> #include<vector> using namespace std;…
( ̄▽ ̄)" //dijkstra算法, //只是有效边(即能从i楼到j楼)的边权都为1(代表次数1): //关于能否到达目标楼层b,只需判断最终lowtime[b]是否等于INF即可. #include<iostream> #include<cstdio> using namespace std; const int INF=10e7; ; int k,minn; int K[MAXN]; int cost[MAXN][MAXN]; int lowtime[MAXN];…
http://acm.hdu.edu.cn/showproblem.php?pid=1548 A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11341    Accepted Submission(s): 4289 Problem Description There is a strange lift.T…
Problem Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP"…
A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29442    Accepted Submission(s): 10641 Problem Description There is a strange lift.The lift can stop can at every floor as you want…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1548 题意:电梯每层有一个数,例如第n层有个数k, 那么这一层只能上k层或下k层,但是不能低于一层或高于n层, 给定起点与终点,要求出最少要按几次键 我的思路:这题可以用bfs或者用最短路(dijsktra) bfs AC代码 #include<cstdio>#include<iostream>#include<cstring>#include<queue>us…
http://acm.hdu.edu.cn/showproblem.php?pid=1548 Online Judge Online Exercise Online Teaching Online Contests Exercise Author F.A.QHand In HandOnline Acmers Forum |DiscussStatistical Charts Problem ArchiveRealtime Judge StatusAuthors Ranklist       C/C…
Problem Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP"…
There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will go up K…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1548 There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you…
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1548 A Strrange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25550    Accepted Submission(s): 9189 Problem Description There is a strange…
There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will go up K…
A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19516    Accepted Submission(s): 7224 Problem Description There is a strange lift.The lift can stop can at every floor as you want,…