POJ 1144 无向图割点模版题
来源:互联网 发布:业务建模与数据挖掘 编辑:程序博客网 时间:2024/06/15 07:15
点击打开链接
题意:给出一个无向图及边的关系,求割点个数
思路:无向图割点纯模版,不多说,这篇写的很好理解点这里
#include <vector>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;const int inf=0x3f3f3f3f;const int maxn=110;vector<int>G[maxn];int E[maxn],L[maxn],vis[maxn],cnt[maxn];int k,kk;void dfs(int x){ k++;E[x]=k;L[x]=k;vis[x]=1; for(unsigned int i=0;i<G[x].size();i++){ int t=G[x][i]; if(!vis[t]){ dfs(t); L[x]=min(L[x],L[t]); if(L[t]>=E[x]&&x!=1) cnt[x]++; else if(x==1) kk++; }else L[x]=min(L[x],E[t]); }}int main(){ int n,a,b,c; while(scanf("%d",&n)!=-1){ if(n==0) break; for(int i=0;i<maxn;i++) G[i].clear(); memset(vis,0,sizeof(vis)); memset(cnt,0,sizeof(cnt)); while(scanf("%d",&a)!=-1){ if(a==0) break; while(getchar()!='\n'){ scanf("%d",&b); G[a].push_back(b); G[b].push_back(a); } } int ans=0; k=0;kk=0;dfs(1); if(kk>=2) ans++; for(int i=1;i<=n;i++){ if(cnt[i]>=1) ans++; } printf("%d\n",ans); } return 0;}
1 0
- POJ 1144 无向图割点模版题
- POJ 1523 无向图割点
- poj 1144 Network【无向图求割顶模板题】
- POJ 2117 Electricity(无向图割点)
- POJ 2117 Electricity(无向图割点)
- POJ 2117 Electricity(无向图割点)
- POJ 1144 Network 无向图求割点
- poj 1144 Network (无向图求割点)
- POJ-1144(无向图割顶)
- poj 1144 Network 无向图求割点
- POJ 1144--Network 【无向图中割点总数】
- POJ 1144 Network 无向图求割点Tarjan
- poj 1144 Network 无向图求割点
- poj 1144 Network 无向连通图求割点
- POJ 1144 Network (无向图求割点)
- 无向图转为由有根树模版、
- poj 3352 无向图
- POJ 1523 无向图求割点
- PAT乙级—1020. 月饼 (25)-native
- ArcGIS教程:什么是 ArcGIS 中的报表?
- libxml2下载地址
- Struts2中动态方法的三种调用方式
- Poco学习笔记
- POJ 1144 无向图割点模版题
- 图像特征检测(Image Feature Detection)
- 应用机器学习建议
- Android之SQLite数据库的使用
- 关于自定义总结
- rpm软件下载地址
- 字符串处理------全排列
- 怎样提高支付系统的安全性及稳定性?
- android Studio for mac 常用快捷键