poj 1523 spf 求割点
来源:互联网 发布:微电影拍摄知乎 编辑:程序博客网 时间:2024/05/16 14:05
无向图求割点的模版题。就是对tarjan的运用。
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn=1e3+9,N=1e3;bool e[maxn][maxn];int dfn[maxn],low[maxn],count,in[maxn];void tarjan(int t,int from){ dfn[t]=low[t]=++count; int ret=0; for(int i=1;i<=N;i++) if(e[t][i]) { if(i==from) continue; if(dfn[i]==-1) { ret++; tarjan(i,t); low[t]=min(low[t],low[i]); if(low[i]>=dfn[t]) in[t]++; } else { low[t]=min(low[t],dfn[i]); } } if(t==from) in[t]=ret-1;}int main(){// freopen("in.txt","r",stdin); int from,to,tcase=0; while(scanf("%d",&from),from) { scanf("%d",&to); e[from][to]=1; e[to][from]=1; while(scanf("%d",&from),from) { scanf("%d",&to); e[from][to]=1; e[to][from]=1; }// printf("hi"); count=0; memset(dfn,-1,sizeof(dfn)); memset(in,0,sizeof(in)); for(int i=1;i<=N;i++) if(dfn[i]==-1) tarjan(i,i); printf("Network #%d\n",++tcase); int cnt=0; for(int i=1;i<=N;i++) { if(in[i]>0) { printf(" SPF node %d leaves %d subnets\n",i,in[i]+1); cnt++; } } if(!cnt) printf(" No SPF nodes\n"); memset(e,0,sizeof(e)); printf("\n"); } return 0;}
- POJ 1523 SPF //求割点
- POJ 1523 SPF 求割点
- POJ 1523 SPF(求割点)
- poj 1523 SPF 求割点
- poj 1523 spf 求割点
- poj 1523 SPF 求割点
- POJ 1523 SPF【求割点】
- POJ 1523 SPF(求割点)
- POJ 1523 SPF Tarjan求割点
- POJ 1523:SPF tarjan求割点
- poj 1523 SPF(tarjan求割点)
- POJ 1523 SPF tarjan求割点模板
- 【POJ 1523】SPF(Tarjan求割点)
- POJ 1523 SPF
- poj 1523 SPF
- POJ 1523 SPF
- poj 1523 SPF
- poj 1523 SPF
- MFC文件复制、删除
- Spring MVC学习(四)-------Controller接口控制器详解4
- 二级指针删除单向链表
- cocos2d Scene场景转换
- android JNI 多线程调用与回调
- poj 1523 spf 求割点
- andriod短信,跟拨号,运行的机制跟思考
- Struts2+Hibernate整合应用开发步骤
- 在Dialog中使用ON_UPDATE_COMMAND_UI来更新控件
- WM_NCHITTEST 消息
- 搜集的几种安装C++4.8的方法
- 选课时间(题目已修改,注意读题) + 母函数
- 结构在使用上的注意点
- Spring MVC学习(四)-------Controller接口控制器详解5