SPF (POJ 1523) Getting started with cutting points

Source: Internet
Author: User

1 /*****************************************2 SPF (POJ 1523)3 Getting started with cutting points4     http://poj.org/problem?id=15235 6 ******************************************/7 8#include <iostream>9#include <algorithm>Ten#include <cstdio> One#include <cstring> A#include <vector> - using namespacestd; -  the Const intm=1005; -vector<int>G[m]; - intDfn[m],low[m]; - intVs[m],num[m]; + intDfs_cut; -  + voidInit () A { at      for(intI=0; i<m;i++) g[i].clear (); -memset (DFN,0,sizeof(DFN)); -memset (Low,0,sizeof(Low)); -Memset (VS,0,sizeof(VS)); -memset (NUM,0,sizeof(num)); -dfs_cut=0; in } -  to voidDfsintu) + { -vs[u]=1; thelow[u]=dfn[u]=++Dfs_cut; *      for(intI=0; I<g[u].size (); i++) $     {Panax Notoginseng         intv=G[u][i]; -         if(!Vs[v]) the         { + Dfs (v); Alow[u]=min (low[u],low[v]); the             if(Low[v]>=dfn[u]) num[u]++; +         } -         Elselow[u]=min (low[u],dfn[v]); $     } $ } -  - intMain () the { -    intu,v,k=1;Wuyi     while(cin>>u&&u) the    { - Init (); WuCin>>v; - G[u].push_back (v); About g[v].push_back (u); $         while(cin>>u&&u) -        { -Cin>>v; - G[u].push_back (v); A g[v].push_back (u); +        } theDfs1); -        if(num[1]) num[1]--;///Num records the number of children, but 1 doesn't have a father, so let it-1, last output the same plus 1 $                                     ///feel num[i]>0 is certain, but do not judge will be wrong, perhaps there are 1 1 this set of data bar.  theprintf"Network #%d\n", k++); the        intflag=1; the         for(intI=1; i<m;i++) the        { -            if(Num[i]) in            { theprintf"SPF node%d leaves%d subnets\n", i,num[i]+1); theflag=0; About            } the        } the        if(flag) printf ("No SPF nodes\n"); theprintf"\ n"); +    } -}

SPF (POJ 1523) Getting started with cutting points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.