HDU 4587 two nodes (dual connection cut point application)

Source: Internet
Author: User

HDU 4587 two nodes (dual connection cut point application)



Question: N points (0 ~ N-1), M undirected edges, and ask the maximum number of connected parts after removing the two points.


First, remove a vertex to find each cut point, in the dfs process, find out how many connected parts are removed from the cut point (Change iscut [u] = true to iscut [u] ++ ),

In this way, you can find the most connected parts for the second time.


#include
 
  #include
  
   #include
   
    #include
    
     #include
     #include
      
       #include
       
        #include
        
         #include
         
          using namespace std;#define M 5005int pre[M],dfs_clock,iscut[M],low[M],bcc_cnt,bccno[M];vector
          
           G[M],bcc[M];struct Edge{ int from,to;}edge[M*2];int edge_num,head[M];void add_edge(int u,int v){ edge[edge_num].from=v; edge[edge_num].to=head[u]; head[u]=edge_num++;}int del;int dfs(int u,int fa){ int lowu=pre[u]=++dfs_clock; for(int i=head[u];i!=-1;i=edge[i].to) { int v=edge[i].from; if(v==del) continue; if(!pre[v]) { int lowv=dfs(v,u); lowu=min(lowv,lowu); if(lowv>=pre[u]) iscut[u]++; } else if(pre[v]
           


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.