首先到每个点的速度实际上是一个定值,就是v0*2^(起点与当前点高度差)

所以当前点i到任意一个相邻点的时间都是一个定值,

不难想到构图最短路径

 const dx:array[..] of integer=(-,,,);
      dy:array[..] of integer=(,,-,);
      inf=; type link=^node;
     node=record
       po:longint;
       len:double;
       next:link;
     end;
     point=record
       num:longint;
       dis:double;
     end; var num,a:array[..,..] of longint;
    d:array[..] of double;
    w:array[..] of link;
    heap:array[..] of point;
    where:array[..] of longint;
    t,i,j,n,m,k,x,y:longint;
    v,vn,mid:double;
    p:link; procedure add(x,y:longint;c:double);
  var p:link;
  begin
    new(p);
    p^.po:=y;
    p^.len:=c;
    p^.next:=w[x];
    w[x]:=p;
  end; procedure swap(var a,b:point);
  var c:point;
  begin
    c:=a;
    a:=b;
    b:=c;
  end; function calc(x:longint):double;
  var i:longint;
  begin
    calc:=;
    if x> then
    begin
      for i:= to x do
        calc:=calc*;
    end
    else if x< then
    begin
      for i:= to abs(x) do
        calc:=calc/;
    end;
  end; procedure sift(i:longint);
  var j,x,y:longint;
  begin
    j:=i shl ;
    while j<=t do
    begin
      if (j+<=t) and (heap[j].dis>heap[j+].dis) then inc(j);
      if heap[i].dis>heap[j].dis then
      begin
        x:=heap[i].num;
        y:=heap[j].num;
        where[x]:=j;
        where[y]:=i;
        swap(heap[i],heap[j]);
        i:=j;
        j:=i shl ;
      end
      else break;
    end;
  end; procedure up(i:longint);
  var j,x,y:longint;
  begin
    j:=i shr ;
    while j> do
    begin
      if heap[i].dis<heap[j].dis then
      begin
        x:=heap[i].num;
        y:=heap[j].num;
        where[x]:=j;
        where[y]:=i;
        swap(heap[i],heap[j]);
        i:=j;
        j:=j shr ;
      end
      else break;
    end;
  end; begin
  readln(v,n,m);
  for i:= to n do
  begin
    for j:= to m do
    begin
      read(a[i,j]);
      inc(k);
      num[i,j]:=k;
    end;
  end;
  for i:= to n do
    for j:= to m do
    begin
      vn:=v*calc(a[,]-a[i,j]);
      for k:= to do
      begin
        x:=i+dx[k];
        y:=j+dy[k];
        if num[x,y]> then add(num[i,j],num[x,y],/vn);
      end;
    end;   n:=n*m;
  t:=n;
  for i:= to n do
  begin
    if i= then d[i]:= else d[i]:=inf;
    heap[i].num:=i;
    heap[i].dis:=d[i];
    where[i]:=i;
  end;
  for i:= to n do
  begin
    x:=heap[].num;
    mid:=heap[].dis;
    if mid=inf then break;
    y:=heap[t].num;
    where[y]:=;
    swap(heap[],heap[t]);
    dec(t);
    sift();
    p:=w[x];
    while p<>nil do
    begin
      y:=p^.po;
      if d[y]>mid+p^.len then
      begin
        d[y]:=mid+p^.len;
        k:=where[y];
        heap[k].dis:=d[y];
        up(k);
      end;
      p:=p^.next;
    end;
  end;
  writeln(d[n]::);
end.

poj3037的更多相关文章

  1. 【POJ3037】Skiing 最短路

    题意: 有个n*m的滑雪场,bessie要从(1,1)滑到(n,m),问最小时间. 起始有一个速度v,然后每从一个点A到一个点B(仅仅能上下左右走,每次一格),速度就会乘上2^(权值A-权值B). 然 ...

  2. POJ3037 Skiing

    Skiing 题目大意: 给定一个M*N的网格,已知在每个网格中的点可以向上下左右四个方向移动一个单位,每个点都有一个高度值. 从每个点开始移动时存在一个速度值,从A点移动到B点,则此时B点的速度为& ...

  3. poj练习题的方法

    poj1010--邮票问题 DFSpoj1011--Sticks dfs + 剪枝poj1020--拼蛋糕poj1054--The Troublesome Frogpoj1062--昂贵的聘礼poj1 ...

  4. POJ 3037 Skiing(如何使用SPFA求解二维最短路问题)

    题目链接: https://cn.vjudge.net/problem/POJ-3037 Bessie and the rest of Farmer John's cows are taking a ...

随机推荐

  1. MFC: Create Directory

    Original link: How to check if Directory already Exists in MFC(VC++)? MSDN Links: CreateDirectory fu ...

  2. linux 下使用crontab 定时打包日志并删除已被打包的日志

    crontab是和用户相关的,每个用户有自己对应的crontab . cron是Linux下的定时执行工具,以下是重启/关闭等等的命令 #/sbin/service crond start //启动服 ...

  3. RabbitMQ RPC问题

    1.服务器端代码:https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/python/rpc_server.py 2.客户端代码:htt ...

  4. 配置Apache+Mysql+Php

    以下操作均在Debian 6.0 64bit 环境root权限下进行,如果提示权限不足请切换至root用户或者sudo,本人比较喜欢自行安装,因为安装的过程中能最小化安装而且能够知道安装了什么,然后可 ...

  5. Qt-获取网络接口信息的综合示例

    在前面的文章中介绍了与 获 取 本 机 网 络 信 息 相 关 的 类 常 用 的 有 4 个 , 分 别 是 : QHostAddress, QHostInfo, QNetworkInterface ...

  6. RX学习笔记:正则表达式

    正则表达式 2016-07-03 正则表达式是以字符串模板的形式匹配查找字符的方式. 正则表达式是字符串模板,所以其本身是一个字符串,首尾以反斜杆 / 开始和结束. 在两反斜杆中间的字符串表示要查找的 ...

  7. sharepoint 脚本 强迫以管理员权限运行

    #region 关键代码:强迫以管理员权限运行 $currentWi = [Security.Principal.WindowsIdentity]::GetCurrent() $currentWp = ...

  8. 51nod贪心算法入门-----任务分配问题

    任务执行顺序 有N个任务需要执行,第i个任务计算时占R[i]个空间,而后会释放一部分,最后储存计算结果需要占据O[i]个空间(O[i] < R[i]). 分析: 可以抽象成,从一个整数开始,每次 ...

  9. RasAPI函数实现PPPOE拨号

    unit uDial; interface uses Windows,Messages, SysUtils, Ras;// Classes; var //EntryName,UserName,Pass ...

  10. pymssql 安装测试

    平台 : windows 7 32位 数据库 : SQLSERVER 2008 python 2.7  & pymssql模块 数据库和python 等模块安装说明省略 以下贴出测试代码: 单 ...