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

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解決問題,詳細(xì)算法:割點與橋
三、代碼

 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 閱讀(1201) 評論(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>
            麻豆乱码国产一区二区三区| 狠狠色狠色综合曰曰| 玉米视频成人免费看| 欧美电影电视剧在线观看| 免费成人网www| 欧美激情中文字幕一区二区| 性色av一区二区三区在线观看| 亚洲国产欧美在线人成| 欧美福利专区| 久久久www| 国产精品爱久久久久久久| 亚洲美女区一区| 亚洲欧美变态国产另类| 亚洲精品国产无天堂网2021| 亚洲欧美日韩综合| 国产精品欧美一区喷水| 你懂的成人av| 国产欧美精品在线| 久久久蜜桃精品| 欧美日韩视频在线第一区| 日韩一级大片在线| 欧美自拍丝袜亚洲| 亚洲免费在线播放| 亚洲女优在线| 亚洲深爱激情| 欧美大片免费观看在线观看网站推荐 | 欧美日本二区| 老司机一区二区三区| 国产精品丝袜白浆摸在线| 亚洲人成在线观看| 亚洲国产导航| 久久婷婷色综合| 久久久久99精品国产片| 国产精品久久久久久久久久免费 | 亚洲国产精品久久久久婷婷老年| 免费在线观看日韩欧美| 久久成人免费| 国产精品入口福利| 久久精品日韩欧美| 国产精品久久久久永久免费观看| 久久国内精品自在自线400部| 香蕉久久夜色精品国产使用方法| 国产亚洲a∨片在线观看| 久久综合激情| 久久综合一区二区| 亚洲欧洲一区二区三区在线观看| 久久精品青青大伊人av| 国产精品久久久久久久久果冻传媒| 欧美一二三视频| 欧美三级视频在线播放| 欧美影院久久久| 国产精品久久久久久久一区探花| 久久福利资源站| 国产亚洲欧洲一区高清在线观看 | 欧美日韩ab| 亚洲精品专区| 亚洲一区视频在线观看视频| 欧美视频三区在线播放| 亚洲作爱视频| 亚洲免费在线精品一区| 国产精品男女猛烈高潮激情| 亚洲欧美日韩精品久久| 久久久久久久高潮| 激情久久久久久| 蜜桃久久av一区| 亚洲国产天堂久久综合网| 国产欧美精品日韩精品| 欧美在线3区| 欧美激情 亚洲a∨综合| 在线视频中文亚洲| 国产精品久久久久久久午夜片| 欧美大片91| 亚洲精品中文字幕在线| 亚洲男人的天堂在线aⅴ视频| 亚洲国产mv| 欧美理论电影在线观看| 亚洲天堂黄色| 久久久水蜜桃av免费网站| 亚洲高清精品中出| 欧美区视频在线观看| 亚洲免费影视| 欧美福利精品| 亚洲调教视频在线观看| 国内久久精品| 欧美日韩国产bt| 欧美一级在线播放| 亚洲三级网站| 欧美自拍丝袜亚洲| 亚洲精品乱码久久久久久久久| 欧美亚洲日本一区| 欧美国产极速在线| 欧美一区午夜精品| 亚洲日产国产精品| 国产一区二区精品丝袜| 亚洲女爱视频在线| 亚洲一区二区在线| 国产在线播精品第三| 欧美福利一区| 久久精品在这里| 亚洲四色影视在线观看| 亚洲风情亚aⅴ在线发布| 欧美一区二区三区日韩| 国产欧美日韩视频一区二区三区 | 国产精品久久综合| 欧美chengren| 午夜欧美不卡精品aaaaa| 亚洲激情在线观看| 免费h精品视频在线播放| 亚洲欧美日韩一区二区| 国产精品久久久久一区二区| 日韩一级在线| 欧美mv日韩mv国产网站| 亚洲三级电影在线观看| 欧美国产综合视频| 欧美在线高清视频| 亚洲无线视频| 午夜久久资源| 一区电影在线观看| 亚洲精品国产精品国自产观看浪潮| 欧美激情视频在线免费观看 欧美视频免费一 | 蜜桃av综合| 欧美伊人影院| 篠田优中文在线播放第一区| 中文在线资源观看视频网站免费不卡| 欧美日韩综合精品| 美女亚洲精品| 久久九九99视频| 欧美一区二区三区在线看 | 免播放器亚洲一区| 亚洲国产天堂久久综合网| 免费观看在线综合| 99精品久久久| 最新日韩在线| 亚洲肉体裸体xxxx137| 亚洲国产一区视频| 亚洲国产精品va在线看黑人动漫| 欧美电影在线观看完整版| 亚洲免费观看在线观看| 亚洲国产成人午夜在线一区| 欧美黄色一区| 亚洲福利视频免费观看| 欧美激情亚洲一区| 亚洲人成网站色ww在线| 欧美一区二区三区免费观看| 亚洲第一福利社区| 影音先锋成人资源站| 亚洲国产精品精华液2区45| 亚洲高清网站| 国产精品综合色区在线观看| 国产精品无人区| 国产精一区二区三区| 国产日韩久久| 在线观看亚洲视频| 亚洲美女在线观看| 亚洲亚洲精品在线观看| 午夜视频精品| 久久综合激情| 亚洲人线精品午夜| 亚洲天堂免费观看| 欧美一区二区三区免费视| 久久精品女人的天堂av| 欧美 亚欧 日韩视频在线| 欧美精品国产精品日韩精品| 国产精品高清一区二区三区| 国产三区二区一区久久| 亚洲国产黄色| 亚洲永久免费| 久色成人在线| 亚洲精品久久久久中文字幕欢迎你| 久久亚洲色图| 亚洲人成网站色ww在线| 午夜精品在线| 免费亚洲电影在线观看| 国产精品爽黄69| 亚洲人成人一区二区在线观看 | 亚洲午夜一区二区| 久久精彩免费视频| 欧美精品自拍| 国产综合婷婷| 亚洲视频在线观看三级| 久久精品国产精品亚洲精品| 亚洲第一黄网| 欧美一区2区三区4区公司二百| 亚洲欧洲精品一区| 国产日韩av高清| 在线综合亚洲| 午夜精品亚洲一区二区三区嫩草| 亚洲品质自拍| 午夜精品网站| 欧美精品九九99久久| 国产欧美va欧美va香蕉在| 国产精品久线观看视频| 亚洲黄一区二区| 午夜精品视频在线观看一区二区 | 欧美伊人久久| 欧美日韩一卡二卡| 樱花yy私人影院亚洲| 欧美一区二区精品| 久久黄色小说| 99re这里只有精品6|