http://acm.hdu.edu.cn/showproblem.php?pid=3671

给出一幅无向图,询问有多少种移除点对的方案使得剩下的连通分量个数大于1.

和上一题差不多的思路直接做n次tarjin即可。

 #include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
#define LL long long
#define pb push_back
const int maxn=;
vector<int>g[maxn];
int dfn[maxn],low[maxn],sub[maxn],root,sum,ban;
bool vis[maxn];
void dfs(int u){
dfn[u]=low[u]=sum++;
vis[u]=;
int son=;
for(int i=;i<g[u].size();++i){
int v=g[u][i];
if(v==ban) continue;
if(vis[v]){
low[u]=min(low[u],dfn[v]);
}
else{
dfs(v);
if(u==root)son++;
else{
if(low[v]>=dfn[u])sub[u]++;
}
low[u]=min(low[u],low[v]);
}
}
if(u==root)sub[u]=son;
else sub[u]++;
}
int main(){
int n,m,cas=,i,j,u,v;
while(scanf("%d%d",&n,&m)==){
if(n==&&m==)break;
for(i=;i<=n;++i)g[i].clear();
while(m--){
scanf("%d%d",&u,&v);
g[u].pb(v);
g[v].pb(u);
}
int ans=;
for(i=;i<=n;++i){
int p=;
ban=i,sum=;
memset(vis,,sizeof(vis));
memset(sub,,sizeof(sub));
for(j=;j<=n;++j){
if(j==ban || vis[j]) continue;
root=j;
p++;
dfs(j);
}
//cout<<"p="<<p<<endl;
for(j=i+;j<=n;++j){
if(sub[j]+p->=)ans++;
}
}
printf("Case %d: %d\n",++cas,ans);
}
return ;
}

hdu-3671-tarjin/割点方案的更多相关文章

  1. HDU - 3671 Boonie and Clyde (图的割点)

    As two icons of the Great Depression, Bonnie and Clyde represent the ultimate criminal couple. Stori ...

  2. POJ 2117 (割点+连通分量)

    题目链接: http://poj.org/problem?id=2117 题目大意:在一个非连通图中,求一个切除图中任意一个割点方案,使得图中连通分量数最大. 解题思路: 一个大陷阱,m可以等于0,这 ...

  3. Tarjan总结(缩点+割点(边)+双联通+LCA+相关模板)

    Tarjan求强连通分量 先来一波定义 强连通:有向图中A点可以到达B点,B点可以到达A点,则称为强连通 强连通分量:有向图的一个子图中,任意两个点可以相互到达,则称当前子图为图的强连通分量 强连通图 ...

  4. tarjin求割点

    题目: hdu3671 http://acm.hdu.edu.cn/showproblem.php?pid=3671 题意:给一个无向图,要求毁掉两个点,使图变得不连通,图一开始是连通的 因为要毁掉两 ...

  5. HDU 1026 (BFS搜索+优先队列+记录方案)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1026 题目大意:最短时间内出迷宫.迷宫里要杀怪,每个怪有一定HP,也就是说要耗一定时.输出方案. 解 ...

  6. HDU 4587 TWO NODES 割点

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4587 题意: 删除两个点,使连通块的数目最大化 题解: 枚举删除第一个点,然后对删除了第一个点的图跑 ...

  7. hdu 5739 割点

    Fantasia Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  8. hdu 2126 Buy the souvenirs 二维01背包方案总数

    Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. HDU 2126 01背包(求方案数)

    Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

随机推荐

  1. NLP--- How to install the tool NLTK in Ubuntu ?

    NLP--- How to install the tool NLTK in Ubuntu ? 1. open the website of NLTK and download it.  https: ...

  2. 光学定位点(mark点)

     Mark点是使用机器焊接时用于定位的点.  表贴元件的pcb更需要设置Mark点,因为在大批量生产时,贴片机都是操作人员手动或者机器自动寻找Mark点进行校准.极少数不设置Mark点也可以,操作非常 ...

  3. 所有JTAG集成电路都应该支持菊花链

    菊花链 在电气和电子工程中,菊花链是一种布线方案,其中多个设备按顺序或环形连接在一起.相邻设备才能通信.菊花链可用于电源,模拟信号,数字数据或其组合. 但是由于菊花链的串联特性,如果任何一个设备从链路 ...

  4. HDU 5754 Life Winner Bo(各类博弈大杂合)

    http://acm.hdu.edu.cn/showproblem.php?pid=5754 题意: 给一个国际象棋的棋盘,起点为(1,1),终点为(n,m),现在每个棋子只能往右下方走,并且有4种不 ...

  5. jQuery从0到1

    jQuery不需要安装,把下载的jquery.js文件放在网站上的一个公共的位置,需要在某个页面使用jQuery时,再相对引用即可.——其中有压缩版和未压缩版,分别用于开发和发布.http://jqu ...

  6. pc网页中嵌入百度地图

    pc网页中嵌入百度地图 1 打开百度地图生成器: http://api.map.baidu.com/lbsapi/creatmap/ 2 设置好了之后,点击获取代码,将代码粘贴到文件中保存为html文 ...

  7. http_load 高并发测试

    安装http_load 下载 sudo wget http://www.acme.com/software/http_load/http_load-09Mar2016.tar.gz 解压 sudo t ...

  8. VC.判断双字节字符集前导字节集(IsDBCSLeadByte)

    ZC:这是 WIndows API 函数 1.“BOOL IsDBCSLeadByte( char );” 判断 某字节是否在 双字节字符集的前导字节集中 ZC:可以判断  如 汉字.日文.韩文等 Z ...

  9. OpenModelica部分库缺失问题解决

    问题:写下面这段代码时,保存时没有出错,但执行时提示找不到initialState这个函数. when time > redTime then state1 := Modelica.Math.R ...

  10. leecode第四题(寻找两个有序数组的中位数)

    题解: class Solution { public: double findMedianSortedArrays(vector<int>& nums1, vector<i ...