POJ 1144 Cut Point

Source: Internet
Author: User

The most basic problem of cutting points, suggest in-depth understanding of the DFS process, and for the same point, to meet it is the condition of the cut point may be set up several times, so be sure to count the number of cut points after the end of the DFS, rather than in the DFS process implemented.

1#include <iostream>2#include <cstring>3#include <cstdio>4 using namespacestd;5 6 Const intN = $;7 Const intM = -;8 intDfn[n];9 intLow[n];Ten intHead[n]; One BOOLIs_cut[n]; A intN, E, dfs_clock; -  - voidInit () the { -E = Dfs_clock =0; -Memset (Head,-1,sizeof(head)); -memset (DFN,0,sizeof(DFN)); +memset (Is_cut,0,sizeof(Is_cut)); - } +  A structEdge at { -     intV, next; - } Edge[m]; -  - voidAddedge (intUintv) - { inEDGE[E].V =v; -Edge[e].next =Head[u]; toHead[u] = e++; + } -  the voidDfsintUintFA) * { $Low[u] = Dfn[u] = + +Dfs_clock;Panax Notoginseng     intCNT =0; -      for(inti = Head[u]; I! =-1; i =edge[i].next) the     { +         intv =edge[i].v; A         if( !Dfn[v]) the         { +cnt++; - Dfs (v, u); $             if(Low[v] >= dfn[u]) is_cut[u] =true; $Low[u] =min (Low[u], low[v]); -         } -         Else if(V! =FA) the         { -Low[u] =min (Low[u], dfn[v]);Wuyi         } the     } -     if(FA <0&& CNT = =1) Is_cut[u] =false; Wu } -  About intMain () $ { -      while(SCANF ("%d", &N), N) -     { - init (); A         intu, v; +          while(SCANF ("%d", &u), u) the         { -              while(GetChar ()! ='\ n' ) $             { thescanf"%d", &v); the Addedge (U, v); the Addedge (V, u); the             } -         } inDfs1, -1 ); the         intAns =0; the          for(inti =1; I <= N; i++ ) About         { the             if(Is_cut[i]) ans++; the         } theprintf"%d\n", ans); +     } -     return 0; the}

POJ 1144 Cut Point

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.