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

 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. MP4(一)-结构

    http://blog.csdn.net/zhuweigangzwg/article/details/17222951 一.基本概念 1.mp4概述 MP4文件中的所有数据都装在box(QuickTi ...

  2. nginx上搭建HLS流媒体服务器

    http://blog.csdn.net/cjsafty/article/details/7922849 简介:HTTP Live Streaming(缩写是 HLS)是一个由苹果公司提出的基于HTT ...

  3. html_table标签和from表单标签小试手

    Html Body中table(表格)也是一个重要组成部分,下面列举一个简单的实例: ——————————————简单的table—————————————————— <!DOCTYPE HTM ...

  4. OC - 8.Quartz2D核心要点

    简介 作用 绘制 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图像) 读取\生成PDF 截图\裁剪图片 自定义UI控件(通常为内部结构较复杂的控件) UIKit中的绝大部分控 ...

  5. swift-08-元组分解和数组

    //1.有时候需要把元组中的数据拆分出来使用比如: var stu = ("范冰冰",30,"女") // 1)将stu中的数据赋值给三个变量. var (na ...

  6. asp.net:验证控件中ValidationExpression的写法

    手机号:"\d{11}"传真号:"\d{7,12}" EMAIL: ".{2,15}@.{2,15}\..{2,4}" 邮箱正则表达式:/^ ...

  7. Flask,HelloWorld

    Flask,HelloWorld # -*- coding:utf-8 -*- ''' Created on 2015年10月19日 ''' from flask import Flask app = ...

  8. HDU 4707 Pet(BFS)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4707 题目大意:在一个无环的,从0开始发散状的地图里,找出各个距离0大于d的点的个数 Sample I ...

  9. Hack--兼容性测试

    CSS hack由于不同的浏览器,比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等,对CSS的解析认识不一样,因此会导致生成的页面效 ...

  10. Linux中的堡垒--iptables

    iptables的构成(四表五链)     表         filter:过滤数据包         nat :转换数据包的源或目标地址         mangle:用来mangle包,改变包的 ...