首先到每个点的速度实际上是一个定值,就是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. 02两栈共享空间_DoubleStack--(栈与队列)

    #include "stdio.h" #include "stdlib.h" #include "io.h" #include " ...

  2. (转)unity开发相关环境(vs、MonoDevelop)windows平台编码问题

    转自: http://www.cnblogs.com/sevenyuan/archive/2012/12/06/2805114.html 1.unity会爆出错误: There are inconsi ...

  3. 11_Jaxws常用注解

    [不使用注解] 默认namespace是服务类包名的倒序 默认portType是服务类的类名 ............... 注解的所起的作用: Jaxws提供的注解可以对WebService的接口规 ...

  4. 关于atoi的实现

    一.关于atoi atol的实现 __BEGIN_NAMESPACE_STD __extern_inline double __NTH (atof (__const char *__nptr)) { ...

  5. 在linux环境下配置node:node + npm + forever

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3574582.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...

  6. sql的集合操作

    原文转自:http://blog.csdn.net/qsyzb/article/details/12560917 SELECT语句的查询结果是元组的集合,所以多个SELECT语句的结果可进行集合操作. ...

  7. 点击按钮文字变成input框,点击保存变成文字

    <!DOCTYPE html><html lang="en"> <head> <meta http-equiv="Content ...

  8. linux 定时执行 cron指令

    linux 中的 cron 定时执行命令,先上例子:每间隙两分钟把 "Hello world"写到 /tmp/hello.txt crontab -e */2 * * * * ec ...

  9. 创建安全的ashx文件,ashx编译

    <%@ WebHandler Language="C#" Class="Handler2" %> using System; using Syste ...

  10. 前端内容缓存技术:CSI,SSI,ESI

    一.CSI (Client Side Includes)   含义:通过iframe.javascript.ajax  等方式将另外一个页面的内容动态包含进来. 原理:整个页面依然可以静态化为html ...