链接

题意为去掉多少个顶点使图不连通,求顶点连通度问题。拆点,构造图,对于<u,v>可以变成<u2,v1> <v2,u1>容量为无穷,<u1,u2>容量为1.那么求出来的最大流(即最小割)就为所需要删除的顶点个数,需要字典序输出,从小到大枚举顶点,如果不加入当前点,最小割变小了的话 ,说明这个点是肯定要删除的。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f
const int N = ;
#define M 160015
struct node
{
int u,v,next;
int w;
} edge[M<<];
int head[N],t,vis[N],pp[N],dis[N];
int o[N];
int st,en;
int x[N][N],f[N];
void init()
{
t=;
memset(head,-,sizeof(head));
}
void add(int u,int v,int w)
{
edge[t].u = u;
edge[t].v = v;
edge[t].w = w;
edge[t].next = head[u];
head[u] = t++;
edge[t].u = v;
edge[t].v = u;
edge[t].w = ;
edge[t].next = head[v];
head[v] = t++;
}
int bfs()
{
int i,u;
int w;
memset(dis,-,sizeof(dis));
queue<int>q;
q.push(st);
dis[st] = ;
while(!q.empty())
{
u = q.front();
q.pop();
for(i = head[u] ; i != - ; i = edge[i].next)
{
int v = edge[i].v;
w = edge[i].w;
if(dis[v]<&&w>)
{
dis[v] = dis[u]+;
q.push(v);
}
}
}
if(dis[en]>) return ;
return ;
}
int dfs(int u,int te)
{
int i;
int s;
if(u==en) return te;
for(i = head[u] ; i != - ; i = edge[i].next)
{
int v = edge[i].v;
int w = edge[i].w;
if(w>&&dis[v]==dis[u]+&&(s=dfs(v,min(te,w))))
{
edge[i].w-=s;
edge[i^].w+=s;
return s;
}
}
dis[u] = -;
return ;
}
int dinic()
{
int flow = ;
int res;
while(bfs())
{
while(res = dfs(st,INF))
flow+=res;
}
return flow;
}
int main()
{
int n,i,j;
while(scanf("%d%d%d",&n,&st,&en)!=EOF)
{
init();
// memset(x,0,sizeof(x));
memset(f,,sizeof(f));
st+=n;
for(i = ; i <= n ; i++)
{
for(j = ; j <= n; j++)
{
scanf("%d",&x[i][j]);
if(i==j)
{
add(i,i+n,);
}
else if(x[i][j])
{
add(i+n,j,INF);
}
}
}
if(x[st-n][en])
{
puts("NO ANSWER!");
continue;
}
int ans = dinic();
int cnt = ;
for(i = ; i <= n ; i++)
{
if(ans==) break;
if(i==st-n||i==en) continue;
f[i] = ;
init();
for(j = ; j <= n ; j++)
{
if(f[j]) continue;
for(int e = ; e <= n ; e++)
{
if(f[e]) continue;
if(j==e)
add(j,j+n,);
else if(x[j][e])
{
add(j+n,e,INF);
}
}
}
int ts = dinic();
if(ts<ans)
{
cnt++;
ans = ts;
}
else f[i] = ;
}
cout<<cnt<<endl;
for(j = ; j <= n; j++)
if(f[j])
printf("%d ",j);
printf("\n");
}
return ;
}

poj1815Friendship(最小割求割边)的更多相关文章

  1. poj 3204(最小割--关键割边)

    Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7 ...

  2. HDU 3251 Being a Hero(最小割+输出割边)

    Problem DescriptionYou are the hero who saved your country. As promised, the king will give you some ...

  3. HDU3987(最小割最少割边)

    Harry Potter and the Forbidden Forest Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65536/ ...

  4. hdu3987,最小割时求最少割边数

    题意:求最小割时候割边最少的数量.算法:先求dinic一遍,跑出残网络,再把该网络中满流量(残量为0)的边 残量改为1,其他边残量改为无穷,则再跑一次最大流,所得即为答案.(思,最小割有喝多组,但是要 ...

  5. HDU - 6214:Smallest Minimum Cut(最小割边最小割)

    Consider a network G=(V,E) G=(V,E) with source s s and sink t t . An s-t cut is a partition of nodes ...

  6. 【HDU4859】 海岸线(网络流-最小割)

    Problem Description 欢迎来到珠海! 由于土地资源越来越紧张,使得许多海滨城市都只能依靠填海来扩展市区以求发展.作为Z市的决策人,在仔细观察了Z市地图之后,你准备通过填充某些海域来扩 ...

  7. 最小割&网络流应用

    重要链接 基础部分链接 : 二分图 & 网络流初步 zzz大佬博客链接 : 网络流学习笔记 重点内容:最小割二元关系新解(lyd's ppt) 题目:网络流相关题目 lyd神犇课件链接 : 网 ...

  8. ZOJ 2753 Min Cut (Destroy Trade Net)(无向图全局最小割)

    题目大意 给一个无向图,包含 N 个点和 M 条边,问最少删掉多少条边使得图分为不连通的两个部分,图中有重边 数据范围:2<=N<=500, 0<=M<=N*(N-1)/2 做 ...

  9. HDU 4859(Bestcoder #1 1003)海岸线(网络流之最小割)

    题目地址:HDU4859 做了做杭电多校,知识点会的太少了.还是将重点放在刷专题补知识点上吧,明年的多校才是重点. 这题题目求的最长周长.能够试想一下,这里的海岸线一定是在"."和 ...

随机推荐

  1. Multitier architecture

    Multitier architecture - Wikipedia https://en.wikipedia.org/wiki/Multitier_architecture Common layer ...

  2. 轮廓线DP:poj 2279 Mr. Young's Picture Permutations

    poj 2279 Mr. Young's Picture Permutations \(solution:\) 首先摘取一些关键词:(每行不超过它后面的行)(每排学生安排高度从左到右减少)(学生的高度 ...

  3. POJ1300 Door Man —— 欧拉回路(无向图)

    题目链接:http://poj.org/problem?id=1300 Door Man Time Limit: 1000MS   Memory Limit: 10000K Total Submiss ...

  4. codeforces B. Online Meeting 解题报告

    题目链接:http://codeforces.com/problemset/problem/420/B 题目意思:给出一段连续的消息记录:记录着哪些人上线或者下线.问通过给出的序列,找出可能为lead ...

  5. hdu 超级楼梯 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2041 哦--对了,这些题读者可以直接忽略,我只是想练习一下自己薄弱的地方...... 题目意思我就不说 ...

  6. kafka条件查询excel拼接

    1 SELECT COUNT(*) FROM wiseweb_crawler_metasearch_page20171214 WHERE (content like '%内蒙古%'or content ...

  7. bzoj2878 [Noi2012]迷失游乐园——概率期望DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2878 这个博客写得很好:https://www.cnblogs.com/qt666/p/72 ...

  8. JAVA interrupte中断线程的真正用途

    Java线程之中,一个线程的生命周期分为:初始.就绪.运行.阻塞以及结束.当然,其中也可以有四种状态,初始.就绪.运行以及结束. 一般而言,可能有三种原因引起阻塞:等待阻塞.同步阻塞以及其他阻塞(睡眠 ...

  9. lnmp-详细编译安装步骤

    CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这 ...

  10. Vue-i18n实现语言切换

    方法1 Vue — i18n 国际化 全局配置 安 装 1.直接引入js文件 <script src="https://unpkg.com/vue/dist/vue.js"& ...