JLOI2010 冠军调查 最小割
var
b,f:array[..] of longint;
s,t,i,j,n,m,x,y:longint;
l,h:array[..]of longint;
a:array[..,..]of longint;
procedure bfs;
var i,head,tail,x,y:longint;
begin
fillchar(b,sizeof(b),);
fillchar(h,sizeof(h),$7f);
h[t]:=;
head:=; tail:=; b[]:=t;
while head<=tail do
begin
x:=b[head];
for i:= to n do
if (a[i,x]>) and (h[i]>=n) then
begin
inc(tail);
b[tail]:=i;
h[i]:=h[x]+;
end;
inc(head);
end;
end;
function dfs(now,inl:longint):longint;
var i,outl:longint;
begin
if now=t then exit(inl);
dfs:=;
for i:=l[now]+ to n do
if (l[i]<n) and (a[now,i]>) and (h[now]=h[i]+) then
begin
if a[now,i]>inl then outl:=dfs(i,inl)
else outl:=dfs(i,a[now,i]);
inl:=inl-outl;
dfs:=dfs+outl;
a[now,i]:=a[now,i]-outl;
a[i,now]:=a[i,now]+outl;
if inl= then break;
inc(l[now]);
end;
end;
function dinic:longint;
var sum:longint;
begin
sum:=;
while h[s]<n do
begin
fillchar(l,sizeof(l),);
sum:=sum+dfs(s,maxlongint);
bfs;
end;
exit(sum);
end;
begin
readln(n,m);
for i:= to n do read(f[i]);
for i:= to n do
if f[i]= then
a[,i+]:= else a[i+,n+]:=;
for i:= to m do
begin
readln(x,y);
a[x+,y+]:=;
a[y+,x+]:=;
end;
s:=;
t:=n+;
n:=n+;
writeln(dinic);
end.
JLOI2010 冠军调查 最小割的更多相关文章
- BZOJ 2768: [JLOI2010]冠军调查 最小割
2768: [JLOI2010]冠军调查 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=2768 Description 一年一度的欧洲足 ...
- 2768: [JLOI2010]冠军调查( 最小割 )
最小割... 怎么乱搞都可以 -------------------------------------------------------------------------------- #inc ...
- 【BZOJ-2768】冠军调查 最小割
2768: [JLOI2010]冠军调查 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 971 Solved: 661[Submit][Status ...
- BZOJ-2768: [JLOI2010]冠军调查(超级裸的最小割)
2768: [JLOI2010]冠军调查 Time Limit: 10 Sec Memory Limit: 128 MB Description 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着 ...
- 【BZOJ2768】[JLOI2010]冠军调查/【BZOJ1934】[Shoi2007]Vote 善意的投票 最小割
[BZOJ2768][JLOI2010]冠军调查 Description 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教 ...
- bzoj2768: [JLOI2010]冠军调查(双倍经验最小割)
2768: [JLOI2010]冠军调查 题目:传送门 题解: 双倍经验(1934) 代码: #include<cstdio> #include<cstring> #inclu ...
- BZOJ2768: [JLOI2010]冠军调查
2768: [JLOI2010]冠军调查 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 484 Solved: 332[Submit][Status ...
- P2057 [SHOI2007]善意的投票 / [JLOI2010]冠军调查
P2057 [SHOI2007]善意的投票 / [JLOI2010]冠军调查 拿来练网络流的qwq 思路:如果i不同意,连边(i,t,1),否则连边(s,i,1).好朋友x,y间连边(x,y,1)(y ...
- 【bzoj2768/bzoj1934】[JLOI2010]冠军调查/[Shoi2007]Vote 善意的投票 最小割
bzoj2768 题目描述 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教育学院进行了一次大规模的调查,调查的内容就是关 ...
随机推荐
- Java集合——Map接口
1.定义 Map用于保存存在映射关系<key,value>的数据.其中,key值不能重复(使用equals()方法比较),value值可以重复 2.方法 V put(key,value) ...
- 15个让人惊讶的 CSS3 动画效果演示
CSS 是网页设计非常重要的一部分,随着越来越多的浏览器对 CSS3 支持的不断完善,设计师和开发者们有了更多的选择.如今,用纯 CSS 就可以实现各种各样很酷的效果,甚至是动画. 本文收集了15个惊 ...
- php圖片中寫入字符串然後生成圖片下載到本地
<?php /** * 生成卡片得類 * Enter description here ... * @author perry * @time 2014-03-03 10:02:20 */ cl ...
- git 安装或者更新
1. 安装编译git时需要的包 # yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel # yum in ...
- ASP.NET MVC的Ajax.ActionLink 的HttpMethod="Get" 一个重复请求的BUG
这段时间使用BootStrap+Asp.net Mvc5开发项目,Ajax.ActionLink遇到一个重复提交的BUG,代码如下: @model IList<WFModel.WF_Temp&g ...
- Thinking in java之正则表达式小例子
public static final String POEM= "Twas brilling, and the slithy toves\n" + "Did gyre ...
- Js练习题之查找字符串中出现最多的字符和个数
如sssfgtdfssddfsssfssss,出现最多的字符是s,出现了12次 传统写法 分析: 1.准备一个空的json,通过循环字符串的每个字符来看,如果json里没有这个字符,就在json里创建 ...
- POJ 2763
题意:给一个数,边之间有权值,然后两种操作,第一种:求任意两点的权值和,第二,修改树上两点的权值. #pragma comment(linker, "/STACK:1024000000,10 ...
- iOS9/iOS8界面对比 XCode7
Xcde7 bate 无需开发这账号(99¥)可以调试程序 目前是测试版 iOS9/iOS8界面对比 (注:左边为iOS8界面,右边为iOS9界面.) 1.新字体 苹果在 iOS9 中使用旧金山字体取 ...
- CodeForces 540C Program D
Description You play a computer game. Your character stands on some level of a multilevel ice cave. ...