Network
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 11042   Accepted: 5100

Description

A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N . No two places have the same number. The lines are bidirectional and always connect together two places and in each place the lines end in a telephone exchange. There is one telephone exchange in each place. From each place it is 
possible to reach through lines every other place, however it need not be a direct connection, it can go through several exchanges. From time to time the power supply fails at a place and then the exchange does not operate. The officials from TLC realized that in such a case it can happen that besides the fact that the place with the failure is unreachable, this can also cause that some other places cannot connect to each other. In such a case we will say the place (where the failure 
occured) is critical. Now the officials are trying to write a program for finding the number of all such critical places. Help them.

Input

The input file consists of several blocks of lines. Each block describes one network. In the first line of each block there is the number of places N < 100. Each of the next at most N lines contains the number of a place followed by the numbers of some places to which there is a direct line from this place. These at most N lines completely describe the network, i.e., each direct connection of two places in the network is contained at least in one row. All numbers in one line are separated 
by one space. Each block ends with a line containing just 0. The last block has only one line with N = 0;

Output

The output contains for each block except the last in the input file one line containing the number of critical places.

Sample Input

5
5 1 2 3 4
0
6
2 1 3
5 4 6 2
0
0

Sample Output

1
2

Hint

You need to determine the end of one line.In order to make it's easy to determine,there are no extra blank before the end of each line.
 
题意:一个数n接下来最多n行(可以少于n行)每行第一个数a  接下来是随机n-1个数b,a和b之间相连  求最后组成的图中割点总数
 
我的输入方法真的不知道错那了   输入略坑
#include<stdio.h>
#include<string.h>
#include<stack>
#include<algorithm>
#define MAX 1100
#define MAXM 2000100
#define INF 0x7fffff
using namespace std;
struct node
{
int beg,end,next;
}edge[MAXM];
int low[MAX],dfn[MAX];
int head[MAX],ans;
int dfsclock;
int iscut[MAX];
void init()
{
ans=0;
memset(head,-1,sizeof(head));
}
void add(int u,int v)
{
edge[ans].beg=u;
edge[ans].end=v;
edge[ans].next=head[u];
head[u]=ans++;
}
void tarjan(int u,int fa)
{
int v,i;
low[u]=dfn[u]=++dfsclock;
int son=0;
for(i=head[u];i!=-1;i=edge[i].next)
{
v=edge[i].end;
if(!dfn[v])
{
son++;
tarjan(v,u);
low[u]=min(low[u],low[v]);
if(u!=fa&&dfn[u]<=low[v])
iscut[u]=1;
}
else
low[u]=min(dfn[v],low[u]);
}
if(fa==u&&son>1)
iscut[u]=1;
}
void find(int l,int r)
{
memset(low,0,sizeof(low));
memset(dfn,0,sizeof(dfn));
memset(iscut,0,sizeof(iscut));
dfsclock=0;
for(int i=l;i<=r;i++)
{
if(!dfn[i])
tarjan(i,i);
}
}
int main()
{
int n,m,j,i,t;
int a,c,len;
char b;
char s[5010];
while(scanf("%d",&n),n)
{
init();
int sum=0; while(scanf("%d", &a), a)
{
while(getchar() != '\n')
{
scanf("%d", &c);
add(a,c);
add(c,a);
}
} // while(scanf("%d",&a),a) 我真的搞不懂我这个输入错在哪里一直wa
// {
// while(scanf("%c",&b)&&b!='\n')
// {
// c=b-'0';
// add(a,c);
// add(c,a);
// }
// } find(1,n);
for(i=1;i<=n;i++)
{
if(iscut[i])
sum++;
}
printf("%d\n",sum);
}
return 0;
}

  

poj 1144 Network【双连通分量求割点总数】的更多相关文章

  1. POJ 1144 Network(无向图连通分量求割点)

    题目地址:id=1144">POJ 1144 求割点.推断一个点是否是割点有两种推断情况: 假设u为割点,当且仅当满足以下的1条 1.假设u为树根,那么u必须有多于1棵子树 2.假设u ...

  2. POJ 1144 Network(Tarjan求割点)

    Network Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12707   Accepted: 5835 Descript ...

  3. POJ 1144 Network(tarjan 求割点个数)

    Network Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17016   Accepted: 7635 Descript ...

  4. poj 1144 Network(无向图求割顶数)

    题目链接:poj 1144 题意就是说有 n(标号为 1 ~ n)个网点连接成的一个网络,critical places 表示删去后使得图不连通的顶点,也就是割顶,求图中割顶的个数. 直接上大白书上的 ...

  5. poj 1144 Network 无向图求割点

    Network Description A Telephone Line Company (TLC) is establishing a new telephone cable network. Th ...

  6. C++[Tarjan求点双连通分量,割点][HNOI2012]矿场搭建

    最近在学图论相关的内容,阅读这篇博客的前提是你已经基本了解了Tarjan求点双. 由割点的定义(删去这个点就可使这个图不连通)我们可以知道,坍塌的挖煤点只有在割点上才会使这个图不连通,而除了割点的其他 ...

  7. poj 1523 SPF(双连通分量割点模板)

    题目链接:http://poj.org/problem?id=1523 题意:给出无向图的若干条边,求割点以及各个删掉其中一个割点后将图分为几块. 题目分析:割点用tarjan算法求出来,对于每个割点 ...

  8. POJ 2117 Electricity 双联通分量 割点

    http://poj.org/problem?id=2117 这个妹妹我竟然到现在才见过,我真是太菜了~~~ 求去掉一个点后图中最多有多少个连通块.(原图可以本身就有多个连通块) 首先设点i去掉后它的 ...

  9. poj 1144 Network 图的割顶判断模板

    Network Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8797   Accepted: 4116 Descripti ...

随机推荐

  1. 洛谷1890 gcd区间

    题目描述 给定一行n个正整数a[1]..a[n].m次询问,每次询问给定一个区间[L,R],输出a[L]..a[R]的最大公因数. 输入输出格式 输入格式: 第一行两个整数n,m.第二行n个整数表示a ...

  2. js事件之神奇的onclick

    21:58 2013/7/1 <a href="#" onclick="alert(123124);" >链接</a> 意思是鼠标点击链 ...

  3. IE9、 Firefox、Safari, Chrome的CSS3圆角属性

    这篇文章主要是记录一下,微软最新发布的 IE9 浏览器CSS 圆角属性,现在CSS3已经 可以轻松实现跨浏览器的圆角效果,包括Firefox高版本,IE9,Safari,Chrome等高端 浏览器. ...

  4. Fckeditor漏洞利用总结

    查看编辑器版本FCKeditor/_whatsnew.html——————————————————————————————————————————————————————— —————— 2. Ver ...

  5. HTTP错误代码详细介绍

    HTTP 400 - 请求无效 HTTP 401.1 - 未授权:登录失败 HTTP 401.2 - 未授权:服务器配置问题导致登录失败 HTTP 401.3 - ACL 禁止访问资源 HTTP 40 ...

  6. 1089-Duplicate Removal

    描述 The company Al's Chocolate Mangos has a web site where visitors can guess how many chocolate cove ...

  7. [模拟]Codeforces509C Sums of Digits

    题目链接 题意:给n个数a[i], 要求b[i]每位数的和等于a[i], 并且b[i]要严格递增 求最小的b[i] b[0]最小一定是X9999...这样的形式 后面的b[i]位数一定大于等于前一个 ...

  8. SQL按日期Datatime来比较大小

    数据库操作中,通常需要选择某日期以后的记录,比如选择10年1月到11年2月之间的记录,此时用SQL语句编写时,不能直接用">.<.="来选择,因为datetime型数据 ...

  9. Altium Designer完美双屏显示方法演示

    布线时我们往往需要对一些信号线做特别的走线处理,这样需要边布线边对照原理图,在protel99中那是一个很痛苦的事,在Altium Designer中这种情况将变很简单. 硬件要求,笔记本+外接显示器 ...

  10. Android USB Host与HID通讯 (二)

    不好意思,从上一篇到现在确实比较忙,中间又外出了一段时间,虽然也上LOFTER,或者看到一些朋友QQ上加我,给我发信息询问,有些看到了有些可能没看到,偶尔回复了一两个,也不咋的详细,在此我想说,一方面 ...