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 题目描述 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教育学院进行了一次大规模的调查,调查的内容就是关 ...
随机推荐
- PLSQL DEVELOPER 连接远程数据库 OCI客户端安装方法
安装使用过PLSQL Dev都知道,要连接数据库,必须配置TNS(Transparence Network Substrate),而直接安装PLSQL Dev 之后,本机是没有Oracle HOME的 ...
- Python eclipse开发环境搭建
http://jingyan.baidu.com/article/cd4c2979101f02756f6e6064.html http://jingyan.baidu.com/article/1876 ...
- placeholder在ie789下无效
<input type="text" class="input" placeholder="用户名/手机号码/邮箱" value=&q ...
- ORACLE数据泵还原(IMPDP命令)【转】
Oracle数据库还原IMPDP命令是相对于EXPDP命令的,方向是反向的.即对于数据库备份进行还原操作.一.知晓IMPDP命令 ? C:\>impdp -help Import: Rele ...
- Git 提交大文件提示 fatal: The remote end hung up unexpectedly
使用gitlab搭建的git server,如果直接使用http的方式去提交的话,提交小文件不会有问题,但是提交大文件时,会出错: fatal: The remote end hung up unex ...
- 开始→运行(cmd)命令大全
gpedit.msc-----组策略 sndrec32-------录音机 Nslookup-------IP地址侦测器 explorer-------打开资源管理器 logoff---------注 ...
- 精通JS 笔记
一,javascript数据类型:undefined,null,boolean,number,string,object 五种加一种复杂类型. 注意大小写,区分大不写函数:functiontypeof ...
- 配置Java环境-20160613
http://jingyan.baidu.com/article/870c6fc33e62bcb03fe4be90.html 1.安装JDK,参照目录 在D:\Program Files\ec ...
- DropMaster
DropMaster 是4个原生 VCL 控件的集合,在 Delphi 和 C++Builder 中使用.虽然包含在 Delphi 和 C++Builder 中的 VCL 组件允许同一程序内窗口之间的 ...
- 创建和运行shell脚本程序
转载请标明http://www.cnblogs.com/winifred-tang94/ 要创建一个shell脚本程序,首先新建一个文本文件,然后在这个文本文件中按照shell编程规则输入shell命 ...