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

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 閱讀(1204) 評論(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>
            性久久久久久久久久久久| 在线免费精品视频| 欧美黄色免费| 欧美中在线观看| 亚洲视频一区二区| 亚洲欧洲日韩在线| 久久久久久自在自线| 亚洲影院污污.| 艳女tv在线观看国产一区| 影音先锋久久久| 国产热re99久久6国产精品| 欧美日本韩国| 欧美激情2020午夜免费观看| 欧美综合国产| 亚洲在线观看视频网站| 99精品国产高清一区二区| 欧美激情第9页| 牛牛影视久久网| 老色鬼久久亚洲一区二区| 久久精品123| 欧美永久精品| 欧美一级二区| 翔田千里一区二区| 亚洲欧美日韩在线不卡| 一本久久a久久精品亚洲| 亚洲激情网站免费观看| 亚洲福利国产| 亚洲国产精品免费| 亚洲国产精品久久久久秋霞不卡| 国产一区二区在线观看免费| 国产视频一区在线| 国产欧美在线播放| 国产欧美一区二区三区视频| 国产乱码精品| 国产亚洲欧美aaaa| 国内外成人免费激情在线视频网站| 国产日韩精品在线播放| 国产偷自视频区视频一区二区| 国产欧美三级| 激情成人综合| 最近中文字幕日韩精品| 亚洲欧洲精品一区二区三区| 亚洲精品一区二区三区av| 亚洲精品五月天| 亚洲午夜久久久久久尤物| 一区二区三区欧美成人| 亚洲欧美日韩国产一区| 欧美伊人久久大香线蕉综合69| 久久精品国产久精国产爱| 久久久五月婷婷| 免费观看在线综合| 亚洲国内自拍| 日韩视频在线免费| 亚洲一区二区在线观看视频| 午夜精品一区二区在线观看| 久久精品国产亚洲aⅴ| 久久综合伊人77777麻豆| 欧美国产三区| 国产精品你懂的在线欣赏| 国内成+人亚洲| 亚洲乱码国产乱码精品精98午夜| 亚洲网站视频| 久久国产色av| 欧美激情一区二区三区四区| 日韩亚洲欧美成人一区| 午夜精品视频在线观看| 免费视频一区二区三区在线观看| 欧美日韩国产黄| 国产日韩欧美视频| 亚洲日本va午夜在线电影| 亚洲天堂av综合网| 久久精品亚洲精品国产欧美kt∨| 开心色5月久久精品| 99精品福利视频| 久久国产精品久久精品国产| 欧美不卡视频一区发布| 国产精品视屏| 亚洲精品系列| 久久精品国产精品| 亚洲精品中文字| 久久成人资源| 欧美日韩在线免费视频| 韩日视频一区| 亚洲女ⅴideoshd黑人| 免费日韩成人| 亚洲婷婷免费| 欧美激情一区二区三区不卡| 国产美女精品视频| 一区二区三区免费观看| 蜜桃av噜噜一区| 亚洲网站啪啪| 欧美精品大片| 在线电影国产精品| 香蕉亚洲视频| 日韩视频专区| 欧美.日韩.国产.一区.二区| 国产精品一卡| 亚洲一区二区三区高清不卡| 免费成人你懂的| 欧美一区二区视频观看视频| 欧美激情一二三区| 欧美在线视频二区| 欧美午夜视频在线观看| 亚洲精品视频免费| 久久在线免费观看视频| 亚洲先锋成人| 欧美日韩1区2区| 亚洲人成网站在线播| 久久一二三国产| 性色一区二区三区| 国产精品久久久久免费a∨| 日韩午夜免费视频| 欧美承认网站| 亚洲欧美日韩国产一区二区| 亚洲网站视频福利| 免费欧美电影| 欧美一区二区三区在线观看| 国产精品扒开腿做爽爽爽软件| 亚洲精品视频二区| 免费精品视频| 久久精品在线观看| 国产日韩精品视频一区二区三区| 亚洲一区三区视频在线观看 | 欧美大学生性色视频| 在线观看亚洲a| 美女图片一区二区| 久久精品盗摄| 狠狠狠色丁香婷婷综合激情| 欧美中文字幕久久| 欧美亚洲尤物久久| 国产日韩欧美一区二区| 小辣椒精品导航| 欧美一区二区大片| 国产一区二区三区久久精品| 久久99在线观看| 欧美在线短视频| 雨宫琴音一区二区在线| 欧美 日韩 国产精品免费观看| 久久伊人亚洲| 亚洲人成网站777色婷婷| 亚洲黄一区二区| 欧美视频不卡中文| 欧美亚洲一区| 久久国产乱子精品免费女| 激情成人中文字幕| 欧美韩日一区| 欧美日韩一二区| 欧美专区日韩视频| 久久国产精品毛片| 亚洲国产精品一区| 亚洲人成毛片在线播放女女| 欧美日韩国产一级片| 午夜欧美不卡精品aaaaa| 午夜日韩在线| 91久久精品www人人做人人爽| 亚洲国产精品999| 欧美午夜免费影院| 久久国产一二区| 欧美成人精品不卡视频在线观看| 夜夜嗨一区二区三区| 亚洲一级在线观看| 激情综合久久| 亚洲三级免费| 国产欧美视频在线观看| 免费亚洲电影在线| 欧美久久成人| 久久精品国产精品亚洲综合| 久热精品视频在线观看一区| 在线性视频日韩欧美| 久久er精品视频| 一本一道久久综合狠狠老精东影业| 国产精品99久久不卡二区| 一区二区三区在线观看欧美| 亚洲精品一二区| 国产在线成人| 亚洲国产精品视频| 国产欧美一区二区三区沐欲 | 欧美精品一区二区三区四区 | 国产一区二区三区网站| 亚洲国产精品第一区二区三区 | 最新精品在线| 小黄鸭精品aⅴ导航网站入口 | 99pao成人国产永久免费视频| 国产视频久久久久久久| 亚洲国产另类久久久精品极度| 国产精品三上| 亚洲黄网站黄| 韩国成人精品a∨在线观看| 亚洲裸体在线观看| 在线成人亚洲| 香蕉乱码成人久久天堂爱免费| 日韩午夜一区| 久久综合色婷婷| 欧美中文字幕在线视频| 欧美三级视频在线观看| 男人插女人欧美| 国产欧美日韩综合一区在线观看 | 国产精品不卡在线| 亚洲电影下载| 伊人夜夜躁av伊人久久|