POJ3177【边双连通分量缩点】
来源:互联网 发布:常用协议端口号 编辑:程序博客网 时间:2024/05/16 12:36
还不会双连通分量的朋友,请扣->这里<-
题意:
No response.
思路:
在一个边双连通分量里面,所有的结点的low[ ]都是一样的哟。
所以可以缩点哟。
缩完点以后一定要证明哟。
//#include <bits/stdc++.h>#include<iostream>#include<cstdio>#include<cstring>#include<stack>#include<set>#include<map>#include<queue>#include<math.h>#include<algorithm>typedef long long LL;using namespace std;//#pragma comment(linker, "/STACK:102400000,102400000")const int INF=0x3f3f3f3f;const int N=5e3+10;struct Edge{ int to; int next; bool cut;} edge[N*4];int tol,head[N],n,m;void init(){ tol=0; memset(head,-1,sizeof(head));}void add(int u,int v){ edge[tol].to=v; edge[tol].next=head[u]; head[u]=tol++;}int low[N],dfn[N];int ind;void Tarjan(int u,int pre){ int v; low[u]=dfn[u]=ind++; for(int i=head[u]; ~i; i=edge[i].next) { v=edge[i].to; if((i^1)==pre) continue; if(!dfn[v]){ Tarjan(v,i); low[u]=min(low[u],low[v]); } else low[u]=min(low[u],dfn[v]); }}int deg[N];void solve(){ memset(deg,0,sizeof(deg)); memset(dfn,0,sizeof(dfn)); ind=1; Tarjan(1,-1); for(int i=1;i<=n;i++) { for(int k=head[i];~k;k=edge[k].next) { int v=edge[k].to; if(low[v] != low[i]) deg[low[i]]++; } } int res=0; for(int i=1;i<=n;i++) if(deg[i]==1) res++; printf("%d\n",(res+1)/2);}int main(){ int u,v; scanf("%d%d",&n,&m); init(); while(m--){ scanf("%d%d",&u,&v); add(u,v); add(v,u); } solve(); return 0;}
0 0
- POJ3177【边双连通分量缩点】
- poj3177 Redundant Paths 边双连通分量
- POJ3177 求边双连通分量
- poj3177 双连通分量
- poj3177 Redundant Paths(边双连通分量+缩点)
- [POJ3177]Redundant Paths 边双连通分量 做题笔记
- 【POJ3177】Redundant Paths-边双连通分量+缩点
- 【poj3177】【双连通分量】Redundant Paths
- poj3177 Redundant Paths 双连通分量
- poj3177 Redundant Paths 双连通分量
- poj3177 边双连通分量+缩点(并查集实现)
- POJ3177 Redundant Paths 3352的双胞胎题 双连通分量
- poj3177 Redundant Paths 无向图 双连通分量 桥
- Redundant Paths-POJ3177(并查集+双连通分量)
- poj3177——Redundant Paths(双连通分量)
- [POJ3177]Redundant Paths Tarjan求双连通分量
- poj3177——Redundant Paths(双连通分量)
- POJ 3352 浅谈边双连通分量缩点
- Unity3d搭建HTTP弱联网的服务器搭建及客户端编写(二)之php服务器
- Unity用Lua开发的 使用度 问题
- oracle删除添加表空间
- 函数——Python学习笔记03
- hdoj 2586
- POJ3177【边双连通分量缩点】
- 有关Canvas图像覆盖问题
- 为什么用接口存常量是一种不良的习惯
- C语言小游戏————反弹球(简单的图形化界面)
- JSON解析类库之Gson(4) --- TypeAdapter接管序列化与反序列化
- android developer tiny share-20170506
- 重置CSS样式表
- Mac OS X配置Java环境变量
- [14]内置对象