求割点和桥模版
来源:互联网 发布:如何抓取淘宝视频 编辑:程序博客网 时间:2024/05/22 01:31
//// main.cpp// Richard//// Created by 邵金杰 on 16/8/18.// Copyright © 2016年 邵金杰. All rights reserved.//#include<iostream>#include<cstdio>#include<cstring>#include<vector>#include<algorithm>using namespace std;const int maxn=200+10;vector<vector<int> > G(maxn);int low[maxn],dfn[maxn],Father[maxn],isCutVectex[maxn];int n,m;int idex=0;void Tarjan(int u,int father){ Father[u]=father; low[u]=dfn[u]=idex++; for(int i=0;i<G[u].size();i++) { int v=G[u][i]; if(!dfn[v]) { Tarjan(v,u); low[u]=min(low[u],low[v]); } else if(v!=father) { low[u]=min(low[u],dfn[v]); } }}void Count(){ memset(isCutVectex,0,sizeof(isCutVectex)); int nRootSons=0; for(int i=2;i<=n;i++) { int v=Father[i]; if(v==1) nRootSons++; else { if(dfn[v]<=low[i]) isCutVectex[v]=1; } } if(nRootSons>1) isCutVectex[1]=1; for(int i=1;i<=n;i++) if(isCutVectex[i]) printf("%d\n",i); for(int i=1;i<=n;i++) { int v=Father[i]; if(v>0&&dfn[v]<low[i]) printf("%d,%d\n",v,i); }}int main(){ int a,b; scanf("%d%d",&n,&m); for(int i=0;i<m;i++) { scanf("%d%d",&a,&b); G[a].push_back(b); G[b].push_back(a); } memset(dfn,0,sizeof(dfn)); memset(low,0,sizeof(low)); memset(Father,0,sizeof(Father)); Tarjan(1,0); Count(); return 0;}//求割点和桥//input//11 13//1 2//1 4//1 5//1 6//2 11//2 3//4 3//4 9//5 8//5 7//6 7//7 10//11 3//output//1//4//5//7//5,8//4,9//7,10
0 0
- 求割点和桥模版
- UVA315 && UVA 796 (求割点和桥,模版)
- 函数模版和类模版
- 函数模版和类模版
- FFT 模版 和 INT128模版
- 别名模版和变量模版
- 求割点模版
- 一个函数模版和类模版实例
- C++函数模版和类模版基础
- C++之函数模版和类模版
- 函数模版、类模版、类模版和宏
- 函数模版和模版函数,类模版和模版类的区别
- 求无向图的 割点和桥 【模版】
- Spring和hibernate配置模版
- 线段树模版和学习
- Velocity和FreeMarker模版技术
- C++ 模版用法和注意事项
- 模版编译和头文件
- App界面原型设计工具
- log4j使用配置教程
- Oracle序列
- 【长篇高能】ReactiveCocoa 和 MVVM 入门
- 关于php后台使用继承模板的理解
- 求割点和桥模版
- Python-selenium:Protected Mode settings are not the same for all zones.
- Android 6.0(api 23) SDK,不再提供org.apache.http.*(只保留几个类)
- win7上 python 安装 lxml
- bzoj 2120: 数颜色 带修改莫队算法
- PS制作文字扫描效果(仿旧效果)
- C++原码、反码、补码详解
- 最近遇到的一些问题总结
- 不管是Wifi 、还是 4G 下都可以获取公网IP地址