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 题目描述 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教育学院进行了一次大规模的调查,调查的内容就是关 ...
随机推荐
- maven install 时提示“程序包 javax.crypto不存在”
但是javax.crypto是在jdk的jre\lib目录下的 解决方案: <compilerArguments> <bootclasspath>${java.home}/li ...
- backbonejs中的模型篇(二)
一:模型标识符 每个模型都有一个用作唯一标识符的ID属性,以便在不同模型间进行区分.通过id属性我们可以直接访问模型对象当中用于标识符存放的属性,默认属性名为id,但也可以通过设置idAttribut ...
- 位运算取第一个非0的位 r & (~(r-1))
Single Number III Given an array of numbers nums, in which exactly two elements appear only once and ...
- was7中文redhat6上安装出现中文乱码解决方案
转:http://blog.csdn.net/w1985g/article/details/8789378 在rhel-server-6.1-x86_64上安装WebSphere 7时,安装界面出现中 ...
- cf731E
题意:一个游戏,由n张贴纸组成.贴纸排成一排,并且纸条上标有数字,玩家轮流揭下m张从左到右连续的纸条(m大等2),揭下后玩家得分累加这些纸条的sum,并且在剩下纸条最左边贴上新的纸条,数值为揭下纸条的 ...
- iOS 登陆的实现四种方式
iOS 登陆的实现四种方式 一. 网页加载: http://www.cnblogs.com/tekkaman/archive/2013/02/21/2920218.ht ml [iOS登陆的实现] A ...
- treap codevs 4543普通平衡树
#include<cstdio>#include<ctime>#include<cstdlib>struct shu{ int l,r,sum1,zhi,dui,s ...
- HTTP(socket)下载遇到valgrind提示的错误: Conditional jump or move depends on uninitialised value(s)
我写了个http下载函数,下载txt.jpg都正常,就是下载php有问题:valgrind会报错Conditional jump or move depends on uninitialised va ...
- NOIP2010解题报告
今天状态不错..1个小时AC了前3题,第四题第一次也拿到了80%的分数,后来换了算法才拿到全部分数.. 第一题: 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 这个翻译软件的原 ...
- string.format
string.Format("{0:#,0}", c.num), //千分号,有小数就保留2位小数 string.Format("{0:N2}", c.amou ...