首先到每个点的速度实际上是一个定值,就是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. [译]CSS content

    原文地址:http://css-tricks.com/css-content/ CSS中有一个属性content,只能和伪元素:before和:after一起使用,他们的写法像伪类选择器(前面有冒号) ...

  2. C++ IO 详细用法

    http://www.cnblogs.com/keam37/ keam所有 转载请注明出处 本文将分别从<iostream>,<sstream>,<fstream> ...

  3. 由Double类型数据到数据的格式化包java.text

    需求:Double类型数据截取操作保留两位小数 解决方案: java.text.DecimalFormat df =new java.text.DecimalFormat("#.00&quo ...

  4. html5 meta头部设置

    <meta name="viewport" content="height=[pixel_value | device-height], width=[pixel_ ...

  5. Ajax请求过程中显示“进度”的简单实现

    Ajax在Web应用中使用得越来越频繁.在进行Ajax调用过程中一般都具有这样的做法:显示一个GIF图片动画表明后台正在工作,同时阻止用户操作本页面(比如Ajax请求通过某个按钮触发,用户不能频繁点击 ...

  6. win7 64 安装Oracle 11G 、使用PLSQL进行连接 标准实践

    第一步: 安装oracle 服务,两个解压包,分别解压后 合并到一个文件夹,点击exe安装 (安装过程中如遇到PATH问题,直接忽略即可) 第二步:使用SQLPlus 测试是否成功 安装成功:CMD ...

  7. 【3】Bootstrap的下载和目录结构

    [1]下载 去中方官网下载http://www.bootcss.com/ 如果你是做网页练习,你可以使用CDN加速服务,免去下载等痛苦,当然你使用的时候必须有连接上网络.中方的官网也提供了很多种类的C ...

  8. 《C和指针》读书笔记——第二章 基本概念

    1.编译过程: source code→Compiler→Object code→Linker←Lib ↓ Exe 2.经过初始化的静态变量(static)在程序执行前能获得他们的值. 3.绝大多数环 ...

  9. __sync_fetch_and_add

    最近在公司离职的前辈写的代码哪里看到了__sync_fetch_and_add这个东东.比较好奇.找些资料学习学习 http://www.lxway.com/4091061956.htm http:/ ...

  10. Mysql zip压缩包安装

    解压mysql.zip 配置环境变量(略) 配置my-default.ini 配置文件 安装mysql:mysqld -install 初始化mysql:mysqld --initialize 启动服 ...