## Luo Gu P3388 [template] cut point (Tarjan)

Given a n-

### Input Format

The first line of input n-, m

The following m

### Output Format

The first output line number cutpoint

The second line node according to an output node from small to large numbers, separated by space

### Sample input and output

Entry
6 7
1 2
1 3
1 4
2 5
3 5
4 5
5 6
Export
1
5

### Description / Tips

For all data,

The numbered points are> 0, <=

tarjan drawings are not necessarily Unicom

. 1 #include <bits / STDC ++ H.>
2  the using  namespace STD;
. 3
. 4  const  int N = 1E5 + . 5 ;
. 5  int n-, m, DEP;
. 6  int DFN [N], Low [N];
. 7 Vector < int > G [N]; /// adjacent table stored FIG
. 8  SET < int > ST; /// memory cutpoint
. 9
10  void Tarjan ( int U, int Father) {
. 11      DFN [U] = Low [U] = ++ DEP ;
12 is      int Child = 0 ;
13 is      for ( int I = 0 ; I <G [U] .size (); I ++ ) {
14          int V = G [U] [I];
15          IF (! DFN [V]) { /// point not visited
16              Tarjan (V, Father);
. 17              Low [U] = min (Low [U], Low [V]);
18 is              IF (U == Father) { /// root subtree quantity statistics
. 19                  child ++ ;
20 is              }
21 is              the else {
22 is                  IF (DFN [U] <= Low [V])
23 is                      st.insert (U);
24              }
25          }
26 is          the else Low [U] = min (Low [U], DFN [V]);
27      }
28      IF (U == && Child Father> = 2 ) /// as a root node and a number of sub-tree is greater than 1, is cut point
29          st.insert (U);
30  }
31 is
32  int main () {
33 is      Scanf ( " % D% D " , & n-, & m);
34 is      the while (M-- ) {
35          int X, Y;
36          Scanf ( " % D% D " , & X, & Y);
37 [          G [X] .push_back (Y);/// undirected graph, deposit bidirectional edge
38 is          G [Y] .push_back (X);
39      }
40      for ( int I = 0 ; I <n-; I ++ ) {
41 is          DEP = 0 ; // drawings are not necessarily communication, each set to 0
42 is          IF (! {DFN [I])
43 is              Tarjan (I, I);
44 is          }
45      }
46 is      the printf ( " % D \ n- " , st.size ());
47      int In Flag = 0 ;
48      for ( SET < int>::iterator it=st.begin();it!=st.end();it++){
49         if(flag) printf(" ");
50         else flag=1;
51         printf("%d",*it);
52     }
53     printf("\n");
54 }

### Guess you like

Origin www.cnblogs.com/ChangeG1824/p/11421255.html
Recommended
Ranking
Daily