青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 18,  comments - 5,  trackbacks - 0

一、題目描述

Description

Consider the two networks shown below. Assuming that data moves around these networks only between directly connected nodes on a peer-to-peer basis, a failure of a single node, 3, in the network on the left would prevent some of the still available nodes from communicating with each other. Nodes 1 and 2 could still communicate with each other as could nodes 4 and 5, but communication between any other pairs of nodes would no longer be possible.

Node 3 is therefore a Single Point of Failure (SPF) for this network. Strictly, an SPF will be defined as any node that, if unavailable, would prevent at least one pair of available nodes from being able to communicate on what was previously a fully connected network. Note that the network on the right has no such node; there is no SPF in the network. At least two machines must fail before there are any pairs of available nodes which cannot communicate.

Input

The input will contain the description of several networks. A network description will consist of pairs of integers, one pair per line, that identify connected nodes. Ordering of the pairs is irrelevant; 1 2 and 2 1 specify the same connection. All node numbers will range from 1 to 1000. A line containing a single zero ends the list of connected nodes. An empty network description flags the end of the input. Blank lines in the input file should be ignored.

Output

For each network in the input, you will output its number in the file, followed by a list of any SPF nodes that exist.

The first network in the file should be identified as "Network #1", the second as "Network #2", etc. For each SPF node, output a line, formatted as shown in the examples below, that identifies the node and the number of fully connected subnets that remain when that node fails. If the network has no SPF nodes, simply output the text "No SPF nodes" instead of a list of SPF nodes.

Sample Input

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

Sample Output

Network #1
SPF node 3 leaves 2 subnets
Network #2
No SPF nodes
Network #3
SPF node 2 leaves 2 subnets
SPF node 3 leaves 2 subnets


二、分析
      用DFS解決問題,詳細算法:割點與橋
三、代碼

 1#include<iostream>
 2#include<list>
 3using namespace std;
 4int t;
 5int v1, v2;
 6list<int> g[1001];
 7bool flag;
 8int root;
 9int counter;
10bool spf[1001];
11int low[1001], lab[1001];
12bool visit[1001];
13void dfs(int u, int fa)
14{
15    low[u] = lab[u] = counter++;
16    list<int>::iterator it;
17    int counter = 0;
18    for(it = g[u].begin(); it != g[u].end(); it++)
19    {
20        int v = *it;
21        if(!lab[v])
22        {
23            counter++;
24            dfs(v, u);
25            low[u] = min(low[u], low[v]);
26            if((u==root && counter>=2|| (u!=root && low[v]>=lab[u]))
27                spf[u] = flag = true;
28        }

29        else if(v != fa)
30            low[u] = min(low[u], lab[v]);
31    }

32}

33void find(int u)
34{
35    visit[u] = true;
36    list<int>::iterator it;
37    for(it = g[u].begin(); it != g[u].end(); it++)
38        if(!visit[*it])
39            find(*it);
40}

41int main()
42{
43    t = 1;
44    while(1)
45    {
46        scanf("%d"&v1);
47        if(v1 == 0break;
48        for(int i=1; i<=1000; i++)
49            g[i].clear();
50        memset(spf, 0sizeof spf);
51        memset(low, 0sizeof low);
52        memset(lab, 0sizeof lab);
53        while(v1 != 0)
54        {
55            scanf("%d"&v2);
56            g[v1].push_back(v2);
57            g[v2].push_back(v1);
58            root = v1;
59            scanf("%d"&v1);
60        }

61        counter = 1;
62        flag = false;
63        dfs(root, -1);
64        printf("Network #%d\n", t++);
65        if(flag)
66        {
67            for(int i=1; i<=1000; i++)
68            {
69                if(!spf[i]) continue;
70                int cnt = 0;
71                memset(visit, 0sizeof visit);
72                visit[i] = true;
73                list<int>::iterator it;
74                for(it = g[i].begin(); it != g[i].end(); it++)
75                    if(!visit[*it])
76                    {
77                        cnt++;
78                        find(*it);
79                    }

80                    printf("  SPF node %d leaves %d subnets\n", i, cnt);
81            }

82        }

83        else
84            printf("  No SPF nodes\n");
85        printf("\n");
86    }

87}
posted on 2009-07-04 16:12 Icyflame 閱讀(1194) 評論(0)  編輯 收藏 引用 所屬分類: 解題報告
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            91久久综合| 久久亚洲精品中文字幕冲田杏梨| 久久久久久黄| 性做久久久久久| 国产欧美在线观看| 久久久久免费视频| 久久久久国产精品厨房| 亚洲国产成人久久综合| 欧美大片va欧美在线播放| 欧美va亚洲va日韩∨a综合色| 亚洲三级电影在线观看| 亚洲国产日韩欧美| 欧美亚一区二区| 久久精品视频免费| 欧美.com| 欧美一区二区大片| 久久久噜噜噜久久人人看| 亚洲精品国产精品久久清纯直播| 亚洲伦理在线免费看| 国产精品亚洲片夜色在线| 久久天天躁狠狠躁夜夜av| 欧美电影电视剧在线观看| 先锋资源久久| 麻豆9191精品国产| 亚洲欧美国产精品va在线观看| 久久精品理论片| 99精品久久| 久久久一区二区| 亚洲欧美日韩久久精品| 久久精品毛片| 亚洲欧美精品在线| 蜜臀久久久99精品久久久久久| 亚洲一区一卡| 老司机午夜精品视频| 亚洲免费视频中文字幕| 另类亚洲自拍| 久久国产精品久久国产精品 | 日韩视频在线一区二区| 国产日韩欧美电影在线观看| 亚洲精品五月天| 在线精品在线| 欧美一级日韩一级| 亚洲视频1区2区| 免费观看一级特黄欧美大片| 欧美一级理论片| 欧美日韩国产小视频| 欧美a一区二区| 国产一区二区久久久| 亚洲一区二区三区视频播放| 亚洲精品资源| 麻豆精品一区二区综合av| 久久精品国产亚洲一区二区三区| 欧美视频免费看| 亚洲日韩欧美视频一区| 亚洲风情亚aⅴ在线发布| 欧美亚洲综合久久| 欧美亚洲自偷自偷| 国产精品va在线| 一区二区欧美精品| 在线亚洲一区| 欧美日韩在线电影| 亚洲美女av在线播放| 亚洲美女视频网| 欧美成人激情视频免费观看| 美国三级日本三级久久99| 国产区亚洲区欧美区| 亚洲桃色在线一区| 香蕉久久a毛片| 国产精品伊人日日| 亚洲欧美另类在线观看| 亚洲欧美日韩专区| 国产日韩欧美一区| 午夜精品亚洲一区二区三区嫩草| 欧美一级在线亚洲天堂| 国产精品视频yy9099| 亚洲欧美激情视频在线观看一区二区三区| 亚洲一二三区在线观看| 国产精品国产一区二区| 亚洲一级影院| 久久精品一二三区| 在线观看日韩www视频免费| 久久综合色婷婷| 91久久香蕉国产日韩欧美9色| 日韩亚洲在线| 国产精品久久久久免费a∨| 亚洲一区国产| 久久婷婷综合激情| 亚洲精品极品| 欧美亚一区二区| 久久人91精品久久久久久不卡| 欧美成人精品在线观看| 一本色道久久综合亚洲精品按摩 | 久久夜精品va视频免费观看| 亚洲国产精品一区二区第四页av| 一本色道久久88综合日韩精品 | 久久人人97超碰国产公开结果| 亚洲国产精品专区久久| 午夜精品亚洲| 亚洲高清视频在线| 国产精品v欧美精品∨日韩| 亚洲欧美日韩天堂一区二区| 牛人盗摄一区二区三区视频| 一区二区免费在线观看| 国产婷婷成人久久av免费高清| 久久深夜福利免费观看| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美一区2区三区4区公司二百| 欧美电影在线观看| 亚洲中字黄色| 亚洲国产视频直播| 国产精品一区一区| 欧美日韩a区| 老司机亚洲精品| 欧美一区二区三区在| 亚洲国产精品第一区二区| 久久精彩免费视频| 一区二区三区久久网| 国模精品一区二区三区| 欧美网站在线观看| 欧美激情视频一区二区三区不卡| 午夜在线视频观看日韩17c| 亚洲精品久久久久中文字幕欢迎你| 久久精品一区二区| 中文久久精品| 亚洲人成在线观看一区二区| 国产视频久久久久| 国产精品一级二级三级| 欧美日本一区二区视频在线观看 | 91久久国产自产拍夜夜嗨 | 亚洲精品综合| 亚洲韩国青草视频| 激情久久中文字幕| 国产日产欧美精品| 国产精品久久久久久久久久三级| 欧美国产视频在线| 久久这里只精品最新地址| 性欧美xxxx视频在线观看| 中文一区二区| 宅男噜噜噜66一区二区 | 欧美高清在线一区二区| 久久视频这里只有精品| 欧美一区日韩一区| 久久精品国产精品| 久久精品一区二区国产| 久久久国产午夜精品| 久久在线视频在线| 久久婷婷国产综合国色天香| 久久蜜桃香蕉精品一区二区三区| 久久国产88| 另类亚洲自拍| 免费人成网站在线观看欧美高清| 欧美成人激情视频免费观看| 欧美成人一区二区三区片免费| 欧美成人激情视频| 亚洲国产精品一区二区第一页| 亚洲人成小说网站色在线| 亚洲清纯自拍| 在线亚洲+欧美+日本专区| 在线综合亚洲| 欧美制服丝袜| 久久综合久久综合九色| 欧美高清在线观看| 欧美视频在线一区| 国产精自产拍久久久久久| 狠狠入ady亚洲精品经典电影| 亚洲第一黄色网| 99热这里只有精品8| 亚洲专区一二三| 久久精品国产99| 欧美高清在线观看| 在线综合欧美| 久久婷婷色综合| 欧美日韩福利| 国产欧美精品xxxx另类| 影音先锋日韩有码| 亚洲一区在线视频| 久久婷婷国产麻豆91天堂| 亚洲欧洲综合另类| 午夜精品久久久久久久99水蜜桃| 久久视频在线视频| 欧美香蕉视频| 在线视频成人| 亚洲女女做受ⅹxx高潮| 蜜臀av性久久久久蜜臀aⅴ四虎| 日韩视频在线观看一区二区| 香蕉久久精品日日躁夜夜躁| 免费在线视频一区| 国产视频亚洲精品| 99国产精品久久| 久久亚裔精品欧美| 99精品欧美一区二区三区综合在线| 欧美在线影院在线视频| 国产精品av久久久久久麻豆网| 激情欧美丁香| 西西裸体人体做爰大胆久久久| 欧美福利一区| 欧美中文在线观看国产| 欧美午夜精品一区二区三区| 亚洲第一福利在线观看| 欧美在线二区|