POJ 1144 Network 裸割点
来源:互联网 发布:辐射4 捏脸数据 编辑:程序博客网 时间:2024/06/01 16:21
题意:
给一个图,求割点个数
#include <cstdio>#include <iostream>#include <cstring>using namespace std;const int MAXN = 110;int low[MAXN], dfn[MAXN], head[MAXN], tail, cnt, timer, n;struct Line{ int to, nxt; }line[ MAXN * MAXN ];bool iscut[MAXN];void add_line( int from, int to ) { line[++tail].nxt = head[from]; head[from] = tail; line[tail].to = to;}void init(){ memset( head, 0, sizeof( head ) ); memset( iscut, false, sizeof( iscut ) ); memset( dfn, 0, sizeof( dfn ) ); tail = 0; cnt = 0; timer = 0;}void Tarjan( int u ) { low[u] = ++timer; dfn[u] = timer; int child = 0; for( register int i = head[u]; i; i = line[i].nxt ) { int v = line[i].to; if( !dfn[v] ) { child++; Tarjan( v ); low[u] = min( low[u], low[v] ); if( low[v] <= u ) iscut[u] = true; } else low[u] = min( low[u], dfn[v] ); } if( u == 1 && child == 1 ) iscut[u] = false;}int main( ) { while( scanf( "%d", &n ) && n ) { init(); int x, y; while( scanf( "%d", &x ) && x ) { while( getchar() != '\n' ) { scanf( "%d", &y ); add_line( x, y ); add_line( y, x ); } } Tarjan( 1 ); for( register int i = 1; i <= n; i++ ) if( iscut[i] ) cnt++; printf( "%d\n", cnt ); } return 0;}
阅读全文
0 0
- POJ 1144 Network 裸割点
- POJ 1144 Network
- POJ 1144 Network
- POJ-1144-Network
- POJ 1144 Network
- POJ 1144 Network
- poj 1144 Network 关节点
- Poj 1144 Network
- POJ-1144 Network 求割点
- POJ 1144 Network 求割点
- POJ 1144 Network
- poj 1144 Network
- poj 1144 Network
- POJ 1144 Network 图论
- poj 1144 Network
- POJ 1144 Network
- POJ 1144 Network
- POJ 1144 Network 笔记
- HDU 2093 考试排名
- HDU 2088 Box of Bricks
- 一个web项目web.xml的配置中<context-param>配置作用
- HDU 2078 复习时间
- HDU 2076 夹角有多大(题目已修改,…
- POJ 1144 Network 裸割点
- 页面效果
- HDU 2073 无限的路
- HDU 2061 Treasure the new start,…
- Vue.js-----轻量高效的MVVM框架(九、组件利用Props传递数据)
- HDU 2060 Snooker
- Cloudera Apache Hadoop 管理员培训—助力进阶大数据知识与技能
- CentOS7使用firewalld打开关闭防火墙与端口
- HDU 1985 Conversions