【POJ3177】Redundant Paths
来源:互联网 发布:潭州seo视频教程92期 编辑:程序博客网 时间:2024/06/08 11:06
#include<iostream>#include<cstdio>#include<cstring>#define N 10005using namespace std;int head[N],low[N],dfn[N],block[N],st[N],inst[N];int ne=1,index,top,scc,d[N];struct data{int to,ne;}e[N*2];void charu(int u,int v){e[++ne].to=v;e[ne].ne=head[u];head[u]=ne;}void tarjan(int x,int fa){low[x]=dfn[x]=++index;st[++top]=x;inst[x]=1;for(int i=head[x];i;i=e[i].ne){if(i==(fa^1))continue;else if(!dfn[e[i].to]){tarjan(e[i].to,i);low[x]=min(low[x],low[e[i].to]);}else if(inst[e[i].to]) low[x]=min(dfn[e[i].to],low[x]);}if(low[x]==dfn[x]){scc++;int t;while(1){t=st[top--];inst[t]=0;block[t]=scc;if(t==x)break;}}}int main(){int n,m,u,v;scanf("%d%d",&n,&m);for(int i=1;i<=m;i++){scanf("%d%d",&u,&v);{charu(u,v);charu(v,u);}}for(int i=1;i<=n;i++) if(!dfn[i])tarjan(1,-1);int sum=0;for(int i=1;i<=n;i++) for(int j=head[i];j;j=e[j].ne) { if(block[i]!=block[e[j].to]) d[block[i]]++; }for(int i=1;i<=n;i++) if(d[i]==1)sum++;printf("%d\n",(sum+1)/2);return 0;}
0 0
- poj3177 - Redundant Paths
- POJ3177--Redundant Paths
- 【POJ3177】Redundant Paths
- poj3177 Redundant Paths
- poj3177 Redundant Paths
- POJ3177 Redundant Paths
- POJ3177 Redundant Paths
- 【poj3177】 Redundant Paths
- poj3177 Redundant Paths
- Redundant Paths(POJ3177)
- 【poj3177】【双连通分量】Redundant Paths
- poj3177 Redundant Paths 边双连通分量
- POJ3177 Redundant Paths (双联通缩点)
- poj3177 Redundant Paths && poj3352 Road Construction
- poj3177 Redundant Paths 双连通分量
- poj3177 Redundant Paths 双连通分量
- poj3177 Redundant Paths(边双联通)
- [POJ3177]Redundant Paths(tarjan求边双)
- Svn Configuration
- 关于WEB前端阅读书籍
- RSSI与LQI、接收距离d之间的关系(转)
- C语言单件模式
- VisionMobile:2014年Q1移动开发者经济报告(六)3、决胜:开发者优选和平台忠诚度
- 【POJ3177】Redundant Paths
- 数字三角形III
- spring 动态创建bean
- 纯CSS3打造动感漂亮的扇形菜单
- AVA基础——图形化界面(GUI)
- Unix与Linux区别、联系
- iOS真机测试的过程
- 还是没爱够,还是没看透,十个美梦盖过了天空
- 苹果App Store审核指南中文翻译