bzoj2709
来源:互联网 发布:java 停顿5秒 编辑:程序博客网 时间:2024/06/04 01:16
http://www.lydsy.com/JudgeOnline/problem.php?id=2709
可以看出s到e的最短路关于v单调不减
二分v做最短路好了
注意精度,要卡到1e-7
program bzoj2709;const eps=1e-7; zl:array [1..4,1..2] of longint=((1,0),(-1,0),(0,1),(0,-1));varp,l,v,s,e:double; t,x,y,tot,sx,sy,ex,ey,r,c,i,j,k:longint; dis:array [0..101,0..101] of double; map:array [0..101,0..101] of char; dl:array [0..1000001] of record x,y:longint; end;begin readln(t); while t>0 do begin dec(t); readln(l,r,c); for i:=0 to r+1 do for j:=0 to c+1 do map[i,j]:='#'; for i:=1 to r do begin for j:=1 to c do begin read(map[i,j]); if map[i,j]='S' then begin sx:=i; sy:=j; end; if map[i,j]='E' then begin ex:=i; ey:=j; end; end; readln; end; s:=0; e:=10; while abs(s-e)>eps do begin v:=(s+e)/2; fillchar(dis,sizeof(dis),87); dl[0].x:=sx; dl[0].y:=sy; tot:=0; dis[sx,sy]:=0; i:=0; while i<=tot do begin for j:=1 to 4 do begin if j<=2 then p:=v else p:=1; x:=dl[i].x+zl[j,1]; y:=dl[i].y+zl[j,2]; if (map[x,y]<>'#')and(dis[x,y]>dis[dl[i].x,dl[i].y]+p) then begin dis[x,y]:=dis[dl[i].x,dl[i].y]+p; inc(tot); dl[tot].x:=x; dl[tot].y:=y; end; end; inc(i); end; if dis[ex,ey]<l then s:=v else e:=v; end; writeln(s:0:5); end;end.
- bzoj2709
- 【bzoj2709】 迷宫花园 spfa
- bzoj2709 [Violet 1]迷宫花园
- BZOJ2709: [Violet 1]迷宫花园
- BZOJ2709: [Violet 1]迷宫花园 二分+Spfa
- bzoj2709 [Violet 1]迷宫花园 二分+spfa
- [bzoj2709][Violet 1]迷宫花园 二分+spfa
- [BZOJ2709][Violet 1]迷宫花园(二分+spfa)
- [bzoj2709][Violet 1]迷宫花园(二分+spfa)
- 几种android效果包括瀑布流
- Java Statement
- 遗传算法入门
- I2C的上拉电阻可以是1.5K,2.2K,4.7K, 电阻的大小对时序有一定影响,对信号的上升时间和下降时间也有影响,一般接1.5K或2.2K
- set_terminate doesn't work
- bzoj2709
- 遗传算法入门
- PhotoShop如何选中一张背景是透明的图片上的非背景图片
- Oracle AWR报告 (awrrpt)转
- SetTimer和KillTimer函数简介
- 孙子定理 中国剩余定理
- Myeclipse中如何更改jsp默认的打开方式
- 2012年Web设计和开发的15个趋势
- 查询强制归档模式