POJ 1144 Network 无向图求割点
来源:互联网 发布:复杂疾病的大数据挖掘 编辑:程序博客网 时间:2024/05/17 23:41
来源:http://poj.org/problem?id=1144
题意:就是给你一些点,某些点之间有边。求有多少个点是割点。
思路:模板题目了,直接用无向图求个点模板就可以ac。需要注意的是输入,输入有点麻烦。以换行结尾可以写成while(getchar() != '\n'),其他没什么难度了。无向图求割点的问题可以参考http://blog.csdn.net/wmn_wmn/article/details/7893157
代码:
#include <iostream>#include <cstdio>#include <string.h>#include <vector>using namespace std;#define CLR(arr,val) memset(arr,val,sizeof(arr))const int N = 110;int low[N],dfn[N],vis[N],numblock[N];vector<int> vv[N];int numcnt,timeorder,numpoint,numson;void init(){CLR(low,0);CLR(dfn,0);CLR(vis,0);CLR(vv,0);CLR(numblock,0);numson = 0;numcnt = 0;timeorder = 0;}int min(int a,int b){return a < b ? a : b;}void dfs(int x){timeorder++;low[x] = dfn[x] = timeorder;vis[x] = 1;for(int i = 0; i < vv[x].size(); ++i){ int y = vv[x][i]; if(!vis[y]){ dfs(y); low[x] = min(low[x],low[y]); if(low[y] >= dfn[x] && x != 1){ numblock[x]++; } else if(x == 1) numson++; } else low[x] = min(low[x],dfn[y]);}}int main(){//freopen("1.txt","r",stdin);while(scanf("%d",&numpoint) && numpoint){init(); int x,y; char ch; while(scanf("%d",&x) && x){ while(getchar() != '\n'){ scanf("%d",&y); vv[x].push_back(y); vv[y].push_back(x); } } dfs(1); for(int i = 1; i <= numpoint; ++i) if(numblock[i]) numcnt++; if(numson > 1) numcnt++; printf("%d\n",numcnt);}return 0;}
- POJ 1144 Network 无向图求割点
- poj 1144 Network (无向图求割点)
- poj 1144 Network 无向图求割点
- POJ 1144 Network 无向图求割点Tarjan
- poj 1144 Network 无向图求割点
- poj 1144 Network 无向连通图求割点
- POJ 1144 Network (无向图求割点)
- POJ 1144--Network 【无向图中割点总数】
- POJ 1144 Network(简单求无向图割顶数)
- POJ 1144 Network(无向图连通分量求割点)
- POJ 1144 Network(简单求无向图割顶数)
- poj 1144 Network【无向图求割顶模板题】
- POJ 1144 Network(简单求无向图割顶数)
- poj 3694 Network 无向图求桥
- UVA 315 Network(无向图求割点)
- uva 315 Network(无向图求割点)
- UVa 315 Network(无向图求割点)
- toj 1026 Network 无向图求割点
- SimpleXMLElement类对象的实例化
- 16进制颜色(html颜色值)字符串转为UIColor
- VC6中使用CHtmlView在对话框控制中显示HTML文件
- RedHat 4 安装 Oracle 10g
- C++的一些深入理解
- POJ 1144 Network 无向图求割点
- 用C#实现pdf文件的完整性验证
- UITextField的leftView
- 关于mvc中的session在controller中传递
- Visual C++快捷键大全 -- 让手指不离开键盘(肯定有你不知道的)
- [Hadoop源码解读](五)MapReduce篇之Writable相关类
- memcache 的内存存储
- 查找----深入探索散列查找
- ORA-00600: internal error code, arguments: [1265]