题目: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. RAC分解步骤之一,在oracle linux 4u4上安装oracle 10.2.0.1.0操作日志

    练习oracle的rac组建过程,第一步,先练习4u4上安装oracle 10.2.0.1.0.直接安装rac,有些难度.从简单的做起.总RAC步骤,参照小布老师的RAC组建. 1. 启动vc,登陆v ...

  2. webapi之jsonp调用

    定义跨域handle public class CorsHandler : DelegatingHandler { const string Origin = "Origin"; ...

  3. jsonp调用webapi和mvc

    webapi代码如下: public string Get(int id) { var callback = HttpContext.Current.Request["callback&qu ...

  4. IOS 学习笔记 2015-04-15 控制器数据反向传值

    // // FirstViewController.h // 控制器数据传递 // // Created by wangtouwang on 15/4/15. // Copyright (c) 201 ...

  5. cp 命令参数

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

  6. php 验证码生成方法 及使用

    基本思路是: 在生成图片的页面中(as: yzm.php)1.设置生成的图片的宽度和高度:2.设置图片要写入的字符:3.截取显示在图片上的字符;4.开启session,把上面截取的字符存放在sessi ...

  7. 关于datagridview单元格不切换焦点无法获得新输入数据的问题解决方法

    问题描述:将EXCEL中的数据导入到dataGridView中,然后通过点击toolStripButton对dataGrideView中的数据进行处理,在测试时,向dataGridView中的某个单元 ...

  8. JavaScript语言用10张图

    JavaScript 语言基础知识点总结,用图片树形结构说明.包括Windows对象.JavaScriptDOM基本操作.JavaScript变量.JavaScript数据类型.JavaScript运 ...

  9. PHP 冒泡排序法

    <?php // 冒泡排序法:将一个数组中的值按照从小到大的顺 序排序 $arr = array(33, 1, 4, 5, 2, 3, 7, 9, 8, 99); $len = count($a ...

  10. #ifndef#define#endif的用法-b

    The special operator defined is used in #if and #elif expressions to test whether a certain name is ...