Point (top cut) cut solution to a problem Luo Gu P3388

Questions surface :

    Cut Point Properties:
    If a cut-point node u, u if and only if there is a subtree subtree is not connected to the side of the ancestors of u (reversion side).
 
  In other words, if for a point u, which is the child node v, if low [v]> = dfn [u], u represents the sub-picture edge without reversion, i.e. the node u is cut point;
 
#include <bits/stdc++.h>
using namespace std;
int n,m;
struct littlestar{
    int to;
    int nxt;
}star[400000];
int head[400000],cnt;
void add(int u,int v)
{
    star[++cnt].to=v;
    star[cnt].nxt=head[u];
    head[u]=cnt;
}
int dfn[20000],low[20000];
int num;
intCO.'s [ 20000 ];
 void Tarjan ( int U, int FA) 
{ 
    DFN [U] = Low [U] ++ = NUM;
     for ( int I = head [U]; I; I = Star [I] .nxt) {
         int V = Star [I] .to;
         IF (! {DFN [V]) 
            Tarjan (V, U); 
            Low [U] = min (Low [U], Low [V]);
             IF (FA && Low [V ]> = DFN [U]) { 
                CO.'s [U] = . 1 ; // Note that, here not count the number of cut points, because some of the multiple entry points may be determined statement, for example, chrysanthemums FIG. 
            } 
        } 
        The else  IF(v!=fa)
        {
            low[u]=min(low[u],dfn[v]);
        }
    }

}
int main ()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1;i<=n;i++){
        if(!dfn[i]) tarjan(i,0);
    }
    int col=0;
    for(int i=1;i<=n;i++){
        if(co[i]){
            ++col;
        }
    }
    cout<<col<<endl;
    for(int i=1;i<=n;i++){
        if(co[i]){
            cout<<i<<" ";
        }
    }
}

 

 

Guess you like

Origin www.cnblogs.com/kamimxr/p/11331332.html