完全是为了拼凑才出出来的吧
先分数规划求出到基地入口的最小安全系数
然后再最小点权覆盖集,只不过这里是带一定精度实数的流,其实是一样的

 const inf=;
eps=0.001;
type way=record
po,next,ti,sa:longint;
end;
node=record
po,next:longint;
flow:double;
end; var w:array[..] of way;
e:array[..] of node;
d:array[..] of double;
numh,h,pp,p,cur,pre:array[..] of longint;
q:array[..] of longint;
v:array[..] of boolean;
i,t,n,m,m1,len,x,y,z,b:longint;
ans:double; function min(a,b:double):double;
begin
if a>b then exit(b) else exit(a);
end; procedure add(x,y,a,b:longint);
begin
inc(len);
w[len].po:=y;
w[len].ti:=a;
w[len].sa:=b;
w[len].next:=pp[x];
pp[x]:=len;
end; procedure ins(x,y:longint;f:double);
begin
inc(len);
e[len].po:=y;
e[len].flow:=f;
e[len].next:=p[x];
p[x]:=len;
end; function check(t:longint;m:double):boolean;
var x,y,f,r,i:longint;
begin
for i:= to n do
d[i]:=inf;
d[n]:=;
fillchar(v,sizeof(v),false);
f:=;
r:=;
q[]:=n;
while f<=r do
begin
x:=q[f];
v[x]:=false;
i:=pp[x];
while i<> do
begin
y:=w[i].po;
if d[y]>d[x]+w[i].ti-m*w[i].sa then
begin
d[y]:=d[x]+w[i].ti-m*w[i].sa;
if (y=t) and (d[y]<=) then exit(true);
if not v[y] then
begin
v[y]:=true;
inc(r);
q[r]:=y;
end;
end;
i:=w[i].next;
end;
inc(f);
end;
if d[t]<= then exit(true) else exit(false);
end; function calc(x:longint):double;
var l,r,m:double;
begin
l:=;
r:=;
if not check(x,) then exit(inf);
while r-l>eps do
begin
m:=(l+r)/;
if check(x,m) then r:=m else l:=m;
end;
exit(r);
end; procedure sap;
var u,i,j,tmp,q:longint;
neck:double;
begin
u:=;
for i:= to t do
cur[i]:=p[i];
numh[]:=t+;
neck:=inf;
while h[]<t+ do
begin
d[u]:=neck;
i:=cur[u];
while i<>- do
begin
j:=e[i].po;
if (e[i].flow>) and (h[u]=h[j]+) then
begin
pre[j]:=u;
cur[u]:=i;
neck:=min(neck,e[i].flow);
u:=j;
if u=t then
begin
ans:=ans+neck;
if ans>inf then exit;
while u<> do
begin
u:=pre[u];
j:=cur[u];
e[j].flow:=e[j].flow-neck;
e[j xor ].flow:=e[j xor ].flow+neck;
end;
neck:=inf;
end;
break;
end;
i:=e[i].next;
end;
if i=- then
begin
dec(numh[h[u]]);
if numh[h[u]]= then exit;
tmp:=t;
q:=-;
i:=p[u];
while i<>- do
begin
j:=e[i].po;
if e[i].flow> then
if tmp>h[j] then
begin
tmp:=h[j];
q:=i;
end;
i:=e[i].next;
end;
h[u]:=tmp+;
inc(numh[h[u]]);
cur[u]:=q;
if u<> then
begin
u:=pre[u];
neck:=d[u];
end;
end;
end;
end; begin
readln(n,m);
for i:= to m do
begin
readln(x,y,z,b);
add(x,y,z,b);
end;
len:=-;
fillchar(p,sizeof(p),);
readln(m1,t);
inc(t);
for i:= to t- do
if i mod = then
begin
ins(i,t,calc(i));
ins(t,i,);
end
else begin
ins(,i,calc(i));
ins(i,,);
end; for i:= to m1 do
begin
readln(x,y);
ins(x,y,inf);
ins(y,x,);
end;
sap;
if ans>inf then writeln(-)
else writeln(ans::);
end.

bzoj2285的更多相关文章

  1. 【BZOJ2285】[SDOI2011]保密(分数规划,网络流)

    [BZOJ2285][SDOI2011]保密(分数规划,网络流) 题面 BZOJ 洛谷 题解 首先先读懂题目到底在干什么. 发现要求的是一个比值的最小值,二分这个最小值\(k\),把边权转换成\(t- ...

  2. BZOJ2285 : [Sdoi2011]保密

    首先通过分数规划,二分答案$mid$,将每条边边权重置为$t-mid\times s$,用DP求出终点到该点的最短路,若非正则可以更小. 如此可以计算出每个出入口的最小危险值,然后把奇点放在$S$,偶 ...

  3. BZOJ2285 [SDOI2011]保密 【01分数规划 + 网络流】

    题目 现在,保密成为一个很重要也很困难的问题.如果没有做好,后果是严重的.比如,有个人没有自己去修电脑,又没有拆硬盘,后来的事大家都知道了. 当然,对保密最需求的当然是军方,其次才是像那个人.为了应付 ...

随机推荐

  1. javascript GB2312转UTF8

    /* * GB2312转UTF8 * 例: * var xx=new GB2312UTF8(); * var Utf8=xx.Gb2312ToUtf8("你aaa好aaaaa"); ...

  2. swing容器继承重绘问题解决

    swing容器继承重绘问题解决   以JPanel为例,继承JPanel,想动态为器更换背景,这就涉及到重绘问题.一下是本人重写代码: package ui; import java.awt.Grap ...

  3. 0基础学习ios开发笔记第一天

    Ios操作 界面操作 快捷键 command + c 复制 command+v 粘贴 command +a 全选 command +s 保存 command +z 撤销 command +x  剪切 ...

  4. C#2.0至4.0 的一些特性

    罗列清单备查 一.C#2.0 1. Partial class 分部类 file1.cs using System; public partial class MyClass { public voi ...

  5. 查内网虚拟机映射的公网IP

    1.访问ip138.com 2.curl ifconfig.me

  6. JNI学习总结

    JNI学习总结 标签(空格分隔): java JNI:Java Native Interface,是一种通过java调用本地方法的技术(当然也可以反过来),随着JDK版本的提升,JNI的效率也一直在提 ...

  7. [Leveldb源码剖析疑问]-block_builder.cc之Add函数

    Add函数是给一个Data block中添加对应的key和value,函数源码如下,其中有一处不理解: L30~L34是更新last_key_的,不理解这里干嘛不直接last_key_ = key.T ...

  8. C程序的构成及动态内存分配

    对一个程序,通常的理解就是,源码编译成机器代码,然后通过机器解释运行.不过是怎样编译成机器代码,和怎样运行的,无疑是个值得探讨的问题.怎样编译成机器代码,过程就是源码的编译.链接,编译器做了这些事.而 ...

  9. AAABBBBCCCC

    语单词词性简写语的意义:,n. 名词 ,noun的缩写v. 动词 , verb的缩写pron. 代词 , pronoun的缩写adj. 形容词, adjective的缩写adv. 副词, adverb ...

  10. js json和对象互相转换

    http://www.jb51.net/article/44562.htm obj = JSON.parse(string) | obj = jQuery.parseJSON(str) 将JSON字符 ...