裸的最小割,拆点时要考虑清楚到底是怎么连
如果之前i->i+n,之后又x->y+n,显然出不了解
所以可以改为i+n->i

如果要输出方案

考虑每一个一个点,如果删去这个点,最小割变小了,那么这个点就是所求点。


不输出方案的代码

# include <bits/stdc++.h>
# define IL inline
# define RG register
# define Fill(a, b) memset(a, b, sizeof(a))
# define Copy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int _(210), __(1e5 + 10), INF(2147483647); IL ll Read(){
RG char c = getchar(); RG ll x = 0, z = 1;
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * z;
} int n, m, w[__], fst[_], nxt[__], to[__], cnt;
int S, T, lev[_], cur[_], max_flow;
queue <int> Q; IL void Add(RG int u, RG int v, RG int f){
w[cnt] = f; to[cnt] = v; nxt[cnt] = fst[u]; fst[u] = cnt++;
w[cnt] = 0; to[cnt] = u; nxt[cnt] = fst[v]; fst[v] = cnt++;
} IL int Dfs(RG int u, RG int maxf){
if(u == T) return maxf;
RG int ret = 0;
for(RG int &e = cur[u]; e != -1; e = nxt[e]){
if(lev[to[e]] != lev[u] + 1 || !w[e]) continue;
RG int f = Dfs(to[e], min(w[e], maxf - ret));
ret += f; w[e ^ 1] += f; w[e] -= f;
if(ret == maxf) break;
}
return ret;
} IL bool Bfs(){
Fill(lev, 0); lev[S] = 1; Q.push(S);
while(!Q.empty()){
RG int u = Q.front(); Q.pop();
for(RG int e = fst[u]; e != -1; e = nxt[e]){
if(lev[to[e]] || !w[e]) continue;
lev[to[e]] = lev[u] + 1;
Q.push(to[e]);
}
}
return lev[T];
} int main(RG int argc, RG char* argv[]){
n = Read(); m = Read(); S = Read(); T = Read() + n; Fill(fst, -1);
for(RG int i = 1; i <= n; i++) Add(i + n, i, 1);
for(RG int i = 1, a, b; i <= m; i++) a = Read(), b = Read(), Add(a, b + n, 1), Add(b, a + n, 1);
while(Bfs()) Copy(cur, fst), max_flow += Dfs(S, INF);
printf("%d\n", max_flow);
return 0;
}

[USACO5.4]奶牛的电信Telecowmunication的更多相关文章

  1. P1345 [USACO5.4]奶牛的电信Telecowmunication

    P1345 [USACO5.4]奶牛的电信Telecowmunication 题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮 ...

  2. 洛谷P1345 [USACO5.4]奶牛的电信Telecowmunication【最小割】分析+题解代码

    洛谷P1345 [USACO5.4]奶牛的电信Telecowmunication[最小割]分析+题解代码 题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流. ...

  3. 洛谷——P1345 [USACO5.4]奶牛的电信Telecowmunication

    P1345 [USACO5.4]奶牛的电信Telecowmunication 题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮 ...

  4. 题解 P1345 【[USACO5.4]奶牛的电信Telecowmunication】

    P1345 [USACO5.4]奶牛的电信Telecowmunication 题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮 ...

  5. AC日记——[USACO5.4]奶牛的电信Telecowmunication 洛谷 P1345

    [USACO5.4]奶牛的电信Telecowmunication 思路: 水题: 代码: #include <cstdio> #include <cstring> #inclu ...

  6. [USACO5.4]奶牛的电信Telecowmunication(网络流)

    P1345 [USACO5.4]奶牛的电信Telecowmunication 题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮 ...

  7. [Luogu P1345] [USACO5.4]奶牛的电信Telecowmunication (最小割)

    题面 传送门:https://www.luogu.org/problemnew/show/P1345 ] Solution 这道题,需要一个小技巧了解决. 我相信很多像我这样接蒟蒻,看到这道题,不禁兴 ...

  8. 洛谷P1345 [USACO5.4]奶牛的电信Telecowmunication

    题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮:如果存在一个由c台电脑组成的序列a1,a2,...,a(c),且a1与a2相 ...

  9. 洛谷P13445 [USACO5.4]奶牛的电信Telecowmunication(网络流)

    题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮:如果存在一个由c台电脑组成的序列a1,a2,...,a(c),且a1与a2相 ...

  10. 洛谷P1345 [USACO5.4]奶牛的电信Telecowmunication(最小割)

    题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮:如果存在一个由c台电脑组成的序列a1,a2,...,a(c),且a1与a2相 ...

随机推荐

  1. Nginx防盗链配置案例配置,Nginx的知识分享

    防盗链的含义:网站内容不在自己服务器上,而通过技术手段,绕过别人放广告有利益的最终页,直接在自己的有广告有利益的页面上向最终用户提供此内容. 常常是一些名不见经传的小网站来盗取一些有实力的大网站的地址 ...

  2. String,StringBuffer,StringBuilder的区别

    数据结构: 数据结构是指相互之间存在一种或多种特定关系的数据元素的集合. 比如数据库就是对硬盘中的数据进行有规则的管理,可以进行增删改查工作,而良好的数据结构可以优化这些操作, 也许大家会想这些和St ...

  3. mac攻略(2) -- apache站点配置

    [http://www.cnblogs.com/redirect/p/6112164.html] Mac OS X 中默认有两个目录可以直接运行你的 Web 程序, 一个是系统级的 Web 根目录:/ ...

  4. 搭建dnsmasq服务器,局域网内部解析

    系统:centos6.5 公司内部需求一台dns server,解析内部域名(该域名不需要在公网上解析) 安装了"bind bind-utils"包,配置里设置转发到外部电信dns ...

  5. 韩信点兵(hanxin)

    相传韩信才智过人,从不直接清点自己军队的人数,只要让士兵先后以三人一排.五人一排.七人一排地变换队形,而他每次只掠一眼队伍的排尾就知道总人数了.输入包含多组数据,每组数据包含3个非负整数a,b,c,表 ...

  6. TensorFlow4Delphi

    https://github.com/hartmutdavid/TensorFlow4Delphi

  7. Node.js的下载、安装、配置、Hello World、文档阅读

    Node.js的下载.安装.配置.Hello World.文档阅读

  8. ICQ

    我一直都想编一个自己的聊天软件,像QQ那种:最近有时间我就自己编了一个.编写的过程中收获很大…… 现在拿出来跟大家分享,有兴趣的朋友可以和我交流交流. 先给大家看一下效果: 启动服务器: 再给大家看一 ...

  9. 算法提高 P1001

    必须感叹下,大数模板就是好用! AC代码: #include <cstdio> #include <cmath> #include <algorithm> #inc ...

  10. 借鉴mini2440的usb-wifi工具集在Beagleboard上移植无线网卡

    配置minicom: sudo yum install minicom sudo minicom -s 选择Serial port setup,此时所示光标在"Change which se ...