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

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>
            欧美日韩精品欧美日韩精品一| 亚洲午夜伦理| 亚洲视频在线视频| 久久免费高清| 国产日韩欧美综合一区| 欧美亚洲在线观看| 欧美日韩国产一区| 亚洲激情婷婷| 美女黄网久久| 性欧美video另类hd性玩具| 欧美午夜免费电影| 这里是久久伊人| 亚洲国产精品久久精品怡红院| 一区二区三区鲁丝不卡| 麻豆91精品91久久久的内涵| 亚洲欧美久久| 国产精品日韩欧美一区二区| 亚洲影音一区| 亚洲一二三四区| 国产精品久久久久久久久久ktv| 亚洲欧洲精品一区| 免费不卡中文字幕视频| 久久精品夜色噜噜亚洲a∨ | 亚洲一级在线| 亚洲欧洲精品成人久久奇米网| 久久精品久久99精品久久| 国产日韩欧美制服另类| 欧美在线视频免费播放| 午夜久久tv| 国产综合视频| 久久噜噜亚洲综合| 欧美一区二区三区在线观看视频| 国产一区二区三区久久悠悠色av | 亚洲欧美日韩精品久久久久| 亚洲日本欧美日韩高观看| 欧美国产综合视频| 一区二区日本视频| 亚洲激情在线观看| 欧美日韩国产999| 在线视频精品一区| 午夜精品久久久久久久白皮肤 | 欧美另类高清视频在线| 亚洲欧美中文日韩v在线观看| 午夜久久资源| 亚洲精品偷拍| 亚洲欧美资源在线| 91久久黄色| 亚洲一区二区在线| 一区二区亚洲欧洲国产日韩| 亚洲国产精品欧美一二99| 国产精品久久久久久久浪潮网站| 久久久久久久久久码影片| 欧美电影免费网站| 欧美一区在线直播| 久久综合色8888| 亚洲欧美激情在线视频| 久久亚洲精品伦理| 亚洲一品av免费观看| 久久高清一区| 一区二区欧美亚洲| 久久综合精品国产一区二区三区| 亚洲视频免费观看| 久久久精品一区二区三区| 在线视频日韩| 久久综合九色综合欧美就去吻| 午夜精品在线观看| 欧美激情一区二区久久久| 久久久久一区二区三区四区| 欧美网站大全在线观看| 欧美激情偷拍| 极品日韩av| 亚洲欧美日韩精品久久亚洲区| 亚洲精品一区在线观看| 久久精品一区二区| 久久av一区二区| 国产精品国产精品| 亚洲黄一区二区三区| 国内揄拍国内精品少妇国语| 一区二区欧美在线观看| 99国内精品久久| 久久综合一区| 玖玖视频精品| 国产私拍一区| 亚洲一二三四久久| 亚洲男同1069视频| 欧美视频不卡中文| 亚洲国产成人高清精品| 黄色另类av| 欧美一区观看| 久久精品国产99国产精品| 国产精品系列在线| 亚洲婷婷免费| 亚洲欧美日韩综合一区| 久久亚洲国产精品日日av夜夜| 久久久夜精品| 乱码第一页成人| 伊人久久男人天堂| 久久九九热免费视频| 久久久久www| 国产一区二区三区自拍| 欧美在线3区| 久久青草福利网站| 在线播放不卡| 麻豆成人在线观看| 欧美国产一区二区在线观看 | 欧美精品在线一区| 亚洲国产天堂久久国产91| 亚洲人午夜精品免费| 欧美国产一区二区| 中文精品视频一区二区在线观看| 亚洲综合色丁香婷婷六月图片| 国产精品卡一卡二卡三| 亚洲一区www| 久久九九久精品国产免费直播| 国内免费精品永久在线视频| 浪潮色综合久久天堂| 欧美激情中文不卡| 亚洲视频1区| 国产精品亚发布| 久久精品视频网| 亚洲国产mv| 午夜精品免费在线| 黄色综合网站| 欧美日韩国产一区二区三区地区| 亚洲性色视频| 麻豆精品视频| 一本大道久久a久久综合婷婷| 国产精品videosex极品| 久久电影一区| 亚洲欧洲一区二区在线播放| 午夜精品一区二区三区电影天堂 | 在线视频欧美精品| 国产日韩欧美在线播放不卡| 免费成人av| 亚洲欧美欧美一区二区三区| 免费观看成人网| 亚洲影视综合| 亚洲精品国产精品国自产在线 | 国产欧美高清| 免费观看久久久4p| 宅男噜噜噜66国产日韩在线观看| 理论片一区二区在线| 亚洲午夜激情| 在线日韩电影| 国产精品美女久久久久久久 | 黄色精品在线看| 国产精品都在这里| 欧美成人精品一区二区| 午夜日韩视频| 99国产精品久久久久老师 | 午夜视频在线观看一区二区三区| 欧美高清你懂得| 久热精品视频在线| 美女脱光内衣内裤视频久久网站| 在线综合+亚洲+欧美中文字幕| 一区免费观看| 国产欧美韩国高清| 欧美日韩在线一区| 蜜臀久久久99精品久久久久久 | 亚洲精品小视频在线观看| 久久视频在线看| 久久国产乱子精品免费女| 亚洲视频在线视频| 亚洲精品欧美极品| 玉米视频成人免费看| 国产一区二区三区在线观看免费| 欧美午夜在线| 欧美日韩国产精品专区| 欧美国产一区在线| 欧美成人免费视频| 麻豆精品精华液| 久久久久久自在自线| 欧美亚洲视频| 午夜老司机精品| 亚洲欧美中文在线视频| 亚洲影视中文字幕| 亚洲欧美变态国产另类| 亚洲一区二区三区在线视频| 一区二区免费在线播放| 夜夜嗨av一区二区三区中文字幕 | 亚洲欧美网站| 亚洲一区久久久| 一区二区日韩免费看| 亚洲性人人天天夜夜摸| 亚洲影院免费观看| 亚洲免费在线| 久久精品亚洲一区二区三区浴池| 久久电影一区| 麻豆久久久9性大片| 欧美高清不卡| 一本不卡影院| 小处雏高清一区二区三区 | 欧美精品一区二区三区视频| 欧美日本一区二区视频在线观看| 欧美日韩国产在线观看| 国产精品户外野外| 国产欧美一区视频| 欲香欲色天天天综合和网| 亚洲毛片在线观看| 亚洲免费影视|