The double connected component of cutting top with undirected graph

Source: Internet
Author: User

POJ1144:

Template problem, but the way of input really really is very very egg ache ... Remember ...

1#include <cstdio>2#include <vector>3#include <cstring>4#include <iostream>5#include <algorithm>6 using namespacestd;7 #defineRep (i,n) for (int i=1;i<=n;i++)8 #defineCLR (x,c) memset (x,c,sizeof (x))9 Const intnmax= the;Ten intDfn[nmax],low[nmax],iscut[nmax],n,dfn_clock; Onevector<int>F[nmax]; A int Get(Char*ch) { -     intx=0; -      for(intI=0; ch[i];i++) thex=x*Ten+ch[i]-'0'; -     returnx; - } - intDfsintUintFA) { +low[u]=dfn[u]=++Dfn_clock; -     intChild=0; +      for(intI=0; I<f[u].size (); i++){ A         intv=F[u][i]; at         if(!Dfn[v]) { -child++; - DFS (v,u); -low[u]=min (low[u],low[v]); -             if(low[v]>=Dfn[u]) -iscut[u]=1; in         } -         Else if(dfn[v]<dfn[u]&&v!=FA) tolow[u]=min (low[u],dfn[v]); +     } -     if(fa<0&&child==1) iscut[u]=0; the     returnLow[u]; *  $ }Panax Notoginseng intMain () { -      while(SCANF ("%d", &n) &&N) { thedfn_clock=0; +CLR (DFN,0); CLR (Iscut,0); A Rep (I,n) f[i].clear (); the         Charch[Ten]; +          while(SCANF ("%s", ch) = =1){ -             if(ch[0]=='0') Break; $             intu=Get(CH); $              while(SCANF ("%s", ch) = =1){ -                 intv=Get(CH); - F[u].push_back (v); the f[v].push_back (u); -                 Chart=GetChar ();Wuyi                 if(t=='\ n') Break; the             } -         } WuDfs1,-1); -         intans=0; About Rep (i,n) $           if(Iscut[i]) -ans++; -printf"%d\n", ans); -     } A     return 0; +}

The double connected component of cutting top with undirected graph

Related Article

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.