优先级队列 + 迪斯拉算法
来源:互联网 发布:软件开发书籍 编辑:程序博客网 时间:2024/04/29 19:36
You are working on the team assisting with programming for the Mars rover. To conserve energy, the rover needs to find optimal paths across the rugged terrain to get from its starting location to its final location. The following is the first approximation for the problem.
N x N square matrices contain the expenses for traversing each individual cell. For each of them, your task is to find the minimum-cost traversal from the top left cell [0][0] to the bottom right cell [N - 1][N - 1]. Legal moves are up, down, left, and right; that is, either the row index changes by one or the column index changes by one, but not both.
Each problem is specified by a single integer between 2 and 125 giving the number of rows and columns in the N x N square matrix. The file is terminated by the case N = 0.
Following the specification of N you will find N lines, each containing N numbers. These numbers will be given as single digits, zero through nine, separated by single blanks.
35 5 43 9 13 2 753 7 2 0 12 8 0 9 11 2 1 8 19 8 9 2 03 6 5 1 579 0 5 1 1 5 34 1 2 1 6 5 30 7 6 1 6 8 51 1 7 8 3 2 39 4 0 7 6 4 15 8 3 2 4 8 37 4 8 4 8 3 40
Problem 1: 20Problem 2: 19Problem 3: 36
速度非常好,达到0.1秒,另外一种是用set优化的,感觉这种更快,更简单
- 优先级队列 + 迪斯拉算法
- 算法之优先级队列
- 算法导论-优先级队列
- 算法:优先级队列
- 多优先级队列调度算法
- 算法练习三 优先级队列
- 堆-实现优先级队列算法
- 《算法导论》 6.5优先级队列
- 优先级队列-数据结构和算法
- 算法-----堆结构实现优先级队列
- 《算法导论》笔记--优先级队列
- 《算法导论》笔记--优先级队列
- 《算法导论》笔记--优先级队列
- 算法导论第六章 优先级队列
- [算法系列之四]优先级队列
- 算法导论笔记(二) : 优先级队列
- 算法导论-优先级队列-C语言
- 【算法导论】堆排序和优先级队列
- Nachos 3.4 安装教程
- 关于分层
- JSP和Servlet面试题精选
- iframe 和 jquery
- 关于GAE/J下的JDO关系(Relationships)
- 优先级队列 + 迪斯拉算法
- cookies 的操作
- C++内存分配异常处理
- Spring AOP
- 处理表重复记录(查询和删除)
- 国米OUT,意甲酱油了
- HDOJ-Monkey and Banana-动态规划
- [转载]C#中使用WindowsSDK
- Ubuntu下django安装