题目描述
在育英,大家最头疼的事情就是晨跑了,因为每天早上大家都要被迫从温暖的被窝爬起来去晨跑令人非常不爽。
育英的晨跑是使用一款APP来规定晨跑路线,我们可以把育英校园看作一个n * m的二维矩阵。LZY的起点在左上角(0,0),而APP规定的终点为右下角(n - 1,m - 1) 。
LZY跑到每个点的用时都不一样,现在LZY为了偷懒,想找一条耗时最短的捷径,你能帮帮他吗?
输入
测试样例由多组测试数据组成。每组测试数据第一行输入两个正整数n , m ( 1 <= n,m <= 100)
接下来输入n * m 个数字 ,每个数字不超过 500
输出
输出LZY从起点跑到终点的最短用时
样例输入
3 3
3 2 1
3 2 1
3 2 1
样例输出
8
和攻城略地一模一样;优先队列的知识点(之前没学好),OK Its My Time。
#include <iostream>
#include <queue>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
using namespace std;
struct node{
int x;
int y;
int ans;
};
struct cmp{
bool operator()(node a,node b){
return a.ans