POJ 3177 Redundant Paths(Tarjan Algorithm求边双连通)
来源:互联网 发布:风水罗盘软件安卓版 编辑:程序博客网 时间:2024/05/16 08:35
low[i]==low[j]则i,j在同一个连通块中。
//// main.cpp// Richard//// Created by 邵金杰 on 16/8/18.// Copyright © 2016年 邵金杰. All rights reserved.//#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const int maxn=1000+10;int map[maxn][maxn],low[maxn],dfn[maxn],du[maxn];int idex=0;int n,m;void Tarjan(int u,int fa){ low[u]=dfn[u]=++idex; for(int i=1;i<=n;i++) { if(map[u][i]) { if(!dfn[i]) { Tarjan(i,u); low[u]=min(low[u],low[i]); } else { if(i!=fa) { low[u]=min(low[u],dfn[i]); } } } }}int main(){ while(scanf("%d%d",&n,&m)!=EOF) { memset(map,0,sizeof(map)); memset(low,0,sizeof(low)); memset(dfn,0,sizeof(dfn)); idex=0; int a,b; for(int i=0;i<m;i++) { scanf("%d%d",&a,&b); map[a][b]=map[b][a]=1; } Tarjan(1,0); memset(du,0,sizeof(du)); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(map[i][j]) { if(low[i]!=low[j]) { du[low[j]]++; } } } } int nCount=0; for(int i=1;i<=n;i++) { if(du[i]==1) nCount++; } printf("%d\n",(int)ceil(nCount/2.0)); } return 0;}
0 0
- POJ 3177 Redundant Paths(Tarjan Algorithm求边双连通)
- [POJ 3177]Redundant Paths[边双连通][Tarjan][缩点]
- POJ-3177 Redundant Paths (边双连通分量[Tarjan])
- 【POJ 3177】Redundant Paths(Tarjan求桥、边双连通分量)
- POJ 3352 Road Construction POJ 3177 Redundant Paths(边双连通图 Tarjan+缩点)
- poj 3177 Redundant Paths(Tarjan,边双连通分量)
- POJ 3177 Redundant Paths(边双连通分量+tarjan)
- poj 3177 Redundant Paths 边双连通
- poj 3177 Redundant Paths 边双连通
- POJ 3177 Redundant Paths (双连通)
- poj 3177 Redundant Paths (双连通)
- poj 3177 Redundant Paths(构造边双连通)
- POJ -- 3177 Redundant Paths(边双连通)
- poj 3177 Redundant Paths tarjan求桥/割边
- POJ 3177--Redundant Paths【无向图增加最少的边成为边双连通图 && tarjan求ebc && 缩点构造缩点树】
- poj 3177 Redundant Paths 【无向图增加最少的边是图成为边—双连通】【tarjan求EBC + 缩点 统计度数为1的EBC】
- poj 3177 Redundant Paths(求最少加几条边将图变为边双连通图)
- poj 3177 Redundant Paths 【图论-边双连通】
- 四大组件之ContentProvider
- poj 3292 Semi-prime H-numbers
- SAX 和 PULL解析服务器文件实例 (部分代码)
- hdu5861 Road,线段树,然后扫描
- OpenSGX 安装编译教程
- POJ 3177 Redundant Paths(Tarjan Algorithm求边双连通)
- JDBC学习笔记(8)——数据库连接池(dbcp&C3P0)
- test
- 一、Android网络编程基本知识
- Codeforces #367 B. Interesting drink(二分)
- 华为 oj 简单密码破解&&汽水瓶&&删除字符串中出现次数最少的字符&&字符串排序
- 类的继承和虚函数
- poj2431Expedition(贪心,优先队列)
- 10个免费在线测试网页性能工具