poj1144 tarjan求割点
来源:互联网 发布:在线php解密 编辑:程序博客网 时间:2024/05/16 02:41
今天下午一开始写dinic的模版竟然错了靠浪费了一个小时
从4点开始学tarjan,凑乎理解了以后开始写模版,然后现在刚刚看的lrj的代码求了割点
应该是最基础的题目了吧
今天早晨起晚了浪费了大概一个小时,所以明天早晨3点半起
#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<stack>#include<vector>#define MAX 8000using namespace std;int n,x,dfn[MAX],low[MAX],in[MAX],belong[MAX];vector<int>edge[MAX];int y,is_cut[MAX],dfs=0;int tarjan(int x,int fa){dfn[x]=low[x]=++dfs;int child=0;for(int j=0;j<edge[x].size();j++){int i=edge[x][j];if(!dfn[i]){child++;int low_i=tarjan(i,x);low[x]=min(low[x],low_i);if(low_i>=dfn[x])is_cut[x]=1;}elseif(dfn[i]<dfn[x]&&i!=fa)low[x]=min(low[x],dfn[i]);}if(fa<0&&child==1)is_cut[x]=0;return low[x];}void solve(){dfs=0;memset(is_cut,0,sizeof(is_cut));tarjan(1,-1);int numcut=0;for(int u=1;u<=n;u++)if(is_cut[u])numcut++;printf("%d\n",numcut);return ;}void debug(){for(int i=1;i<=n;i++){printf("%d__________________",i);for(int j=0;j<edge[i].size();j++)printf("%d ",edge[i][j]);printf("\n");}return ;}int main(){while(scanf("%d",&n)&&n){for(int i=1;i<=n;i++)edge[i].clear();memset(dfn,0,sizeof(dfn));memset(in,0,sizeof(in));memset(low,0,sizeof(low));while(scanf("%d",&x)&&x)while(getchar()!='\n'){scanf("%d",&y);edge[x].push_back(y);edge[y].push_back(x);}//debug();solve();}return 0;}
0 0
- poj1144-tarjan求割点
- poj1144 tarjan求割点
- poj1144 - tarjan求割点
- [poj1144 Network]tarjan求割点
- poj1144(tarjan求割点)
- POJ1144--Network(Tarjan求割点)
- [POJ1144]Network(tarjan求割点)
- POJ1144——Tarjan+计算割点
- POJ1144 Network 求割点
- poj1144-Network(求割点)
- poj1144 求割点 模版题
- POJ1144 Network(求割点)
- uva315/poj1144 network 求割点
- poj1144(求割点)
- poj1144 求割点的个数
- POJ1144
- poj1144
- POJ1144
- sql server中clustered index scan,table scan,index scan
- Onvif开发之客户端鉴权获取参数篇
- UML(五)对象图
- c语言文件的简单实例和说明
- 0-1背包问题
- poj1144 tarjan求割点
- 设置自己的RadASM颜色
- C/C++下rand()产生随机数的用法
- Python中的匿名函数-lambda
- tornado开发学习之2.输入输出,数据库操作,内置模板,综合示例
- nmon使用说明
- android-将文字保存为png图片,将Bitmap保存为图片
- SenchaTouch的弹出框,每次都先执行hide后在执行show的解决方案
- 一些HEVC相关链接