题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFnoi%E8%80%83%E5%90%8E%E6%AC%A2%E4%B9%90%E8%B5%9B%29/%E6%9C%80%E5%A4%A7%E4%BC%A4%E5%AE%B3

题解:发现我最小割还是不怎么会T_T

而且此题题意有些不明。。。

看到出题人说就是选出一大坨,然后能加的都加。卧槽,这不是最大权闭合子图吗?

最大权闭合子图中原来有边的现在连边为inf,表示i与j必须同割,那我们连边为x,就代表i,j不同割需要扣除多少。

然后求出最小割,用总权值减去最小割,好象是对的?然后就A掉了。。。

代码:

 #include<cstdio>

 #include<cstdlib>

 #include<cmath>

 #include<cstring>

 #include<algorithm>

 #include<iostream>

 #include<vector>

 #include<map>

 #include<set>

 #include<queue>

 #include<string>

 #define inf 1000000000

 #define maxn 2000+5

 #define maxm 1000000

 #define eps 1e-10

 #define ll long long

 #define pa pair<int,int>

 #define for0(i,n) for(int i=0;i<=(n);i++)

 #define for1(i,n) for(int i=1;i<=(n);i++)

 #define for2(i,x,y) for(int i=(x);i<=(y);i++)

 #define for3(i,x,y) for(int i=(x);i>=(y);i--)

 #define mod 1000000007

 using namespace std;

 inline int read()

 {

     int x=,f=;char ch=getchar();

     while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}

     while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}

     return x*f;

 }
int n,m,s,t,sum,maxflow,tot=,a[maxn],b[maxn][maxn],head[maxn],cur[maxn],h[maxn],q[maxn]; struct edge{int go,next,v;}e[maxm]; void ins(int x,int y,int z){e[++tot].go=y;e[tot].v=z;e[tot].next=head[x];head[x]=tot;} void insert(int x,int y,int z){ins(x,y,z);ins(y,x,);} bool bfs() { for(int i=s;i<=t;i++)h[i]=-; int l=,r=;q[]=s;h[s]=; while(l<r) { int x=q[++l]; for(int i=head[x];i;i=e[i].next) if(e[i].v&&h[e[i].go]==-) { h[e[i].go]=h[x]+;q[++r]=e[i].go; } } return h[t]!=-; } int dfs(int x,int f) { if(x==t) return f; int tmp,used=; for(int i=cur[x];i;i=e[i].next) if(e[i].v&&h[e[i].go]==h[x]+) { tmp=dfs(e[i].go,min(e[i].v,f-used)); e[i].v-=tmp;if(e[i].v)cur[x]=i; e[i^].v+=tmp;used+=tmp; if(used==f)return f; } if(!used) h[x]=-; return used; } void dinic() { maxflow=; while(bfs()) { for (int i=s;i<=t;i++)cur[i]=head[i];maxflow+=dfs(s,inf); } } int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); n=read();m=read();s=;t=n+m+;
for1(i,n+m)a[i]=read()*;
for1(i,n)for1(j,n)b[i][j]=read();
for1(i,n)for1(j,m)b[i][j+n]=b[j+n][i]=read();
for1(i,m)for1(j,m)b[i+n][j+n]=read();
for1(i,n+m)
{
int t1=,t2=;
if(a[i]>)t1+=a[i],sum+=a[i];else t2+=abs(a[i]);
for1(j,n+m)if(b[i][j])
{
t1+=b[i][j];
if(b[i][j]>)insert(i,j,b[i][j]),sum+=b[i][j];
}
if(t1)insert(s,i,t1);
if(t2)insert(i,t,t2);
}
dinic();
printf("%d\n",(sum-maxflow)/); return ; }

Beta Round #9 (酱油杯noi考后欢乐赛)最大伤害的更多相关文章

  1. Beta Round #9 (酱油杯noi考后欢乐赛)乌鸦喝水

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  2. Beta Round #9 (酱油杯noi考后欢乐赛)随机数生成器

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  3. Beta Round #9 (酱油杯noi考后欢乐赛)PLQ和他的小伙伴们

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  4. Beta Round #9 (酱油杯noi考后欢乐赛)PLQ的寻宝

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  5. 洛谷---小L和小K的NOIP考后放松赛

    链接: https://www.luogu.org/contestnew/show/11805?tdsourcetag=s_pcqq_aiomsg 题解: 没人过的题我就没看 t2: 考虑每个点是朋友 ...

  6. Codeforces Beta Round #57 (Div. 2)

    Codeforces Beta Round #57 (Div. 2) http://codeforces.com/contest/61 A #include<bits/stdc++.h> ...

  7. Codeforces Beta Round #52 (Div. 2)

    Codeforces Beta Round #52 (Div. 2) http://codeforces.com/contest/56 A #include<bits/stdc++.h> ...

  8. Codeforces Beta Round #46 (Div. 2)

    Codeforces Beta Round #46 (Div. 2) http://codeforces.com/contest/49 A #include<bits/stdc++.h> ...

  9. Codeforces Beta Round #31 (Div. 2, Codeforces format)

    Codeforces Beta Round #31 (Div. 2, Codeforces format) http://codeforces.com/contest/31 A #include< ...

随机推荐

  1. cordova安装中的坑

    1.安装android环境直接略过! 2.安装node.js直接略过! 3.安装cordova npm install -g cordova npm uninstall cordova  -g(这条是 ...

  2. ios专题 - 异步下载加下载进度显示

    [罗国强原创] 今天被刺激了,愤概地要写下这边博文. 说到http异步下载,首先要知道其中的关键类. 关键类是NSURLConnection  NSURLRequest NSMutableURLReq ...

  3. 如何在Angular2中使用jquery

    首先在index.html中引入jquery文件 <script src="http://cdn.bootcss.com/jquery/2.1.3/jquery.js"> ...

  4. 04_过滤器Filter_04_Filter生命周期

    [Filter生命周期] [init(FilterConfig filterConfig) throws ServletException] *和Servlet程序类似,Filter的创建和销毁由we ...

  5. Android从服务端获取json解析显示在客户端上面

    Android从服务端获取json解析显示在客户端上面 百度经验:jingyan.baidu.com 首先说一下Json数据的最基本的特点,Json数据是一系列的键值对的集合,和XML数据来比,Jso ...

  6. cp 命令参数

    cp命令         该命令的功能是将给出的文件或目录拷贝到另一文件或目录中,同MSDOS下的copy命令一样,功能十分强大.         语法: cp [选项] 源文件或目录 目标文件或目录 ...

  7. jquery放大镜插件与样式

    这是放大镜插件链接,我已经上传到我博客http://files.cnblogs.com/valiant1882331/%E6%94%BE%E5%A4%A7%E9%95%9C%E6%8F%92%E4%B ...

  8. c#中创建类(更新中)

    类是最常见的一种引用类型,最简单的定义如下 class YouClassNam {} 复杂的类可能包含一下内容 类属性 类属性以及类修饰符.  非嵌套的类修饰符有:public,internal,ab ...

  9. e.target与事件委托简例

    target定义: target 事件属性可返回事件的目标节点(触发该事件的节点),如生成事件的元素.文档或窗口. 语法: event.target event.target.nodeName  // ...

  10. 支付宝开发(一)-认识php openssl RSA 非对称加密实现

    获取支付宝公钥 本地服务器生成私钥和公钥 运用php中openssl相关函数加密解密验证身份 以下是php中openssl相关函数实现的验证,来自php官方demo //需要签名的数据 $data = ...