POJ 1144 Network (Tarjan求割点)
来源:互联网 发布:亿程旅行社 知乎 编辑:程序博客网 时间:2024/06/05 17:16
http://poj.org/problem?id=1144
题意:求割点的个数。
裸模板。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <vector>using namespace std;const int N = 110;int dfn[N],low[N];bool cut[N];int rt ,rt_num,dep;vector<int> vet[N];void dfs(int u){ dfn[u] = low[u] = ++dep; for(int i=0; i<vet[u].size();i++) { int v = vet[u][i]; if(!dfn[v]) { dfs(v); if(u==rt) rt_num++; else { low[u] = min(low[u],low[v]); if(low[v] >= dfn[u]) cut[u] = true; } } else low[u] = min(low[u],dfn[v]); } return;}int main(){ //freopen("data.in","r",stdin); int n; while(scanf("%d",&n)!=EOF && n) { for(int i=1;i<=n;i++) vet[i].clear(); int x,y; char ch; while(scanf("%d",&x)!=EOF && x) { while(scanf("%d%c",&y,&ch)!=EOF) { vet[x].push_back(y); vet[y].push_back(x); if(ch=='\n') break; } } rt = 1, rt_num = 0; memset(dfn,0,sizeof(dfn)); memset(cut,false,sizeof(cut)); dfs(1); int ans = 0; dep = 0; if(rt_num>1) cut[rt]=true; for(int i=1;i<=n;i++) if(cut[i]) ans++; cout<<ans<<endl; } return 0;}
0 0
- POJ 1144 Network 求割点(tarjan)
- POJ 1144 Network (Tarjan求割点)
- poj 1144 Network (tarjan求割点)
- 【POJ 1144】Network(Tarjan求割点)
- poj 1144 Network(Tarjan求割点)
- [poj 1144]Network[Tarjan求割点]
- Poj 1144 Network【Tarjan求割点】
- POJ 1144 Network(Tarjan)
- POJ 1144 Network ---tarjan算法求割点
- [POJ 1144] Network Tarjan算法求割点
- POJ 1144 Network 无向图求割点Tarjan
- poj 1144 Network (tarjan割点模板)
- poj 3694 Network(tarjan + LCA)
- poj 3694 Network(Tarjan+LCA)
- POJ 3694Network (tarjan bcc + LCA)
- poj 3694 Network (tarjan+树链剖分)
- poj 1236 Network of Schools (tarjan)
- POJ1144--Network(Tarjan求割点)
- 杭电2734 Quicksum
- JavaScript基础——浏览器对象模型(BOM)
- CSS3 动画 Animation
- UVA 题目10617 - Again Palindrome(区间DP)
- Spring、Spring事务详解;使用XML配置事务
- POJ 1144 Network (Tarjan求割点)
- poj 1422 Air Raid(最小路径覆盖)
- poj 3984 迷宫问题【BFS && DFS】【简单】
- js 实现倒计时
- iOS_ 摸推背景透明效果
- HDOJ--1827--Summer Holiday(强连通分量的最小代价连接)
- coreGraphics绘图
- spring获取数组参数(二)
- Cocos-2d js 多个精灵都调用同一个动作 执行不成功(加“.copy()“)