POJ 3177(带重边的连通图的双连通分量)
来源:互联网 发布:浙大教务网络管理系统 编辑:程序博客网 时间:2024/05/26 05:52
题目大意:求带重边的连通图至少加几条边变成双连通图
POJ 3352+重边
用邻接矩阵的表示无压力
Program P3177;const maxn=1000; maxm=1000;var n,m,i,j,x,y:longint; b:array[1..maxn,1..maxn] of boolean; indegree,c,a,low:array[1..maxn] of longint; time:longint;function min(a,b:longint):longint;begin if a<b then exit(a) else exit(b);end;function max(a,b:longint):longint;begin if a>b then exit(a) else exit(b);end;procedure tarjan(k,father:longint);var i,j:longint;begin inc(time); a[k]:=time; low[k]:=time; c[k]:=1; for i:=1 to n do begin if (b[i,k]) and (i<>father) and (a[i]<a[k]) then begin if c[i]=0 then begin tarjan(i,k); low[k]:=min(low[k],low[i]); end; if (c[i]=1) and (i<>father) then begin low[k]:=min(low[k],a[i]); end; end; end; c[k]:=2;end;procedure main;var i,j,tot:longint;begin fillchar(a,sizeof(a),0); fillchar(low,sizeof(low),0); fillchar(c,sizeof(c),0); fillchar(indegree,sizeof(indegree),0); time:=0; tarjan(1,0); for i:=1 to n do for j:=i+1 to n do if (low[i]<>low[j]) and (b[i,j]) then begin inc(indegree[low[i]]); inc(indegree[low[j]]); end; tot:=0; for i:=1 to n do if indegree[i]=1 then inc(tot); writeln((tot+1) div 2);end;begin fillchar(b,sizeof(b),false); read(n,m); for i:=1 to m do begin read(x,y); b[x,y]:=true; b[y,x]:=true; end; main;end.
- POJ 3177(带重边的连通图的双连通分量)
- poj 3352(无向图的双连通分量)
- POJ 3352 & 3177 无向图的边-双连通分量(无重边 & 重边)
- 无向连通图的割点,割边(桥),双连通分量。
- POJ 3352 边的双连通分量
- POJ 2942 点的双连通分量
- POJ 3177 Redundant Paths 边的双连通分量
- poj 2942 双连通分量+二分图的染色判断
- 无向图的双连通分量
- 【无向图的双连通分量】
- 无向图的双连通分量
- 无向图的双连通分量
- 双连通分量的求解
- poj 3177 & 3352 【无向图双连通分量Tarjan】
- poj 3177 割边(双连通分量)
- poj 3177 边双连通分量(处理重边)
- POJ 3177 Redundant Paths(边双连通分量)
- POJ-3177 Redundant Paths (边双连通分量[Tarjan])
- 苦逼程序员的北京生活2
- Mysql show用法以及慢查询日志的开启
- Mysql 索引优化
- Linux内核驱动之Input子系统设备驱动层
- java的cglib动态代理报java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter
- POJ 3177(带重边的连通图的双连通分量)
- 矩阵链乘法
- Mysql memory表引擎
- ZOJ3643 Keep Deleting
- WCF双工通信
- mysql-replication数据库同步
- 彩影ARP防火墙 v6.0.2(x64)的问题 错误代码1/0 解决方案
- 写给刚入职场的你
- 鸟菜基础篇_2012_8_26序列化