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 冠军调查 最小割的更多相关文章

  1. BZOJ 2768: [JLOI2010]冠军调查 最小割

    2768: [JLOI2010]冠军调查 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=2768 Description 一年一度的欧洲足 ...

  2. 2768: [JLOI2010]冠军调查( 最小割 )

    最小割... 怎么乱搞都可以 -------------------------------------------------------------------------------- #inc ...

  3. 【BZOJ-2768】冠军调查 最小割

    2768: [JLOI2010]冠军调查 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 971  Solved: 661[Submit][Status ...

  4. BZOJ-2768: [JLOI2010]冠军调查(超级裸的最小割)

    2768: [JLOI2010]冠军调查 Time Limit: 10 Sec  Memory Limit: 128 MB Description 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着 ...

  5. 【BZOJ2768】[JLOI2010]冠军调查/【BZOJ1934】[Shoi2007]Vote 善意的投票 最小割

    [BZOJ2768][JLOI2010]冠军调查 Description 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教 ...

  6. bzoj2768: [JLOI2010]冠军调查(双倍经验最小割)

    2768: [JLOI2010]冠军调查 题目:传送门 题解: 双倍经验(1934) 代码: #include<cstdio> #include<cstring> #inclu ...

  7. BZOJ2768: [JLOI2010]冠军调查

    2768: [JLOI2010]冠军调查 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 484  Solved: 332[Submit][Status ...

  8. P2057 [SHOI2007]善意的投票 / [JLOI2010]冠军调查

    P2057 [SHOI2007]善意的投票 / [JLOI2010]冠军调查 拿来练网络流的qwq 思路:如果i不同意,连边(i,t,1),否则连边(s,i,1).好朋友x,y间连边(x,y,1)(y ...

  9. 【bzoj2768/bzoj1934】[JLOI2010]冠军调查/[Shoi2007]Vote 善意的投票 最小割

    bzoj2768 题目描述 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教育学院进行了一次大规模的调查,调查的内容就是关 ...

随机推荐

  1. 201. Bitwise AND of Numbers Range -- 连续整数按位与的和

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  2. android:configChanges属性

    对android:configChanges属性,一般认为有以下几点: 1.不设置Activity的android:configChanges时,切屏会重新调用各个生命周期,切横屏时会执行一次,切竖屏 ...

  3. poj1190 生日蛋糕(深搜+剪枝)

    题目链接:poj1190 生日蛋糕 解题思路: 深搜,枚举:每一层可能的高度和半径 确定搜索范围:底层蛋糕的最大可能半径和最大可能高度 搜索顺序:从底层往上搭蛋糕,在同一层尝试时,半径和高度都是从大到 ...

  4. Idea添加Jetty时提示JMX module is not included

    添加自己的jetty时提示下图 此时,我们应该编辑jetty根目录下 start.ini 添加 "--module=jmx" 此时就可以成功添加了 原因:因为在9.07的时候默认情 ...

  5. 报错总结_java.lang.RuntimeException: Invalid action class configuration that references an unknown class name

    在使用SSH进行项目开发时,一不小心就可能出现以上的错误提示. 这样的问题可以简单理解为未找到名字为XXX的action 1)xxxAction没有在Struts.xml中配置相应的action: 大 ...

  6. PHP换行符详解 PHP_EOL,<br />

    1.PHP_EOL:用于文本的换行符,经常用于日志文件记录.可以解决: 在windows中\r\n是换行在Mac中\r是换行在Liunx中\n是换行 不统一的问题. 2. <br /> : ...

  7. vs2016 vsto excel addin deploy error: vsto 无法解析属性type的值

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/ea33e391-21d7-4f54-92cb-c7af72f19c61/outlook- ...

  8. HDU 5768 中国剩余定理

    题目链接:Lucky7 题意:求在l和r范围内,满足能被7整除,而且不满足任意一组,x mod p[i] = a[i]的数的个数. 思路:容斥定理+中国剩余定理+快速乘法. (奇+ 偶-) #incl ...

  9. static详解

    static关键字用来修饰属性.方法,称这些属性.方法为静态属性.静态方法. static关键字声明一个属性或方法是和类相关的,而不是和类的某个特定的实例相关,因此,这类属性或方法也称为“类属性”或“ ...

  10. django.test.client 使用随记

    import os,sys,django; sys.path.append("\\path\\to\\mysite")#ATTETION!,Err: "unable to ...