链接

题意为去掉多少个顶点使图不连通,求顶点连通度问题。拆点,构造图,对于<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. 解决pyspark-linux-windowsIDE JAVA_HOME not set

    对 os.environ 赋值 ssh://root@192.168.2.51:22/usr/bin/python -u /home/data/tmp_test/trunk/personas/tmp_ ...

  2. golang---信号signal

    golang中os/signal包的使用 chenbaoke · 2015-06-17 20:03:59 · 2748 次点击 · 预计阅读时间 1 分钟 · 不到1分钟之前 开始浏览 这是一个创建于 ...

  3. regmap使用介绍【转】

    本文转载自:http://blog.csdn.net/hellowxwworld/article/details/10737569 内核3.1引入一套新的API regmap,目的是提取出关于I2C ...

  4. bzoj3727: PA2014 Final Zadanie

    我真是SB之神呢这么SB的题都不会 肯定是先无脑正向思考,罗列下关系式: b[1]=∑a[i]*dep[i]=∑tot[i] (i!=1) b[i]=b[fa]-tot[i]+(tot[1]-tot[ ...

  5. POJ1426 Find The Multiple —— BFS

    题目链接:http://poj.org/problem?id=1426 Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Tota ...

  6. kafka条件查询excel拼接

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

  7. 【Maven】pom.xml(2)

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. 网易短信接口集成 nodejs 版

    /* name:网易短信服务集成nodejs版: author:zeq time:20180607 test: // checkValidCode('157****6954','284561').th ...

  9. 【USACO06NOV】路障

    [题目链接] 点击打开链接 [算法] 最短路 [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 5000 #de ...

  10. Vue之组件的内容分发

    aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUF ...