Problem:
Articulation Points

Find articulation points of a given undirected graph G(V, E).

A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.

Input

|V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1

, where |V| is the number of vertices and |E| is the number of edges in the graph. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively.

si and ti represent source and target verticess of i-th edge (undirected).

Output

A list of articulation points of the graph G ordered by name.

Constraints

1 ≤ |V| ≤ 100,000

0 ≤ |E| ≤ 100,000

The graph is connected

There are no parallel edges

There are no self-loops

Sample Input 1

4 4
0 1
0 2
1 2
2 3

Sample Output 1

2

Sample Input 2

5 4
0 1
1 2
2 3
3 4

Sample Output 2

1
2
3

Solution in C++14 (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;

struct lowlink{
  vector<int> ord,low,used;
  vector<vector<int>> adj,tree;
  int root,n;
  lowlink(){}
  lowlink(vector<vector<int>> const& a,int r):adj(a),root(r){
    n = adj.size();
    ord.resize(n);
    low.resize(n);
    used.resize(n,-1);
    tree.reserve(n);
    int k=0;
    dfs(r,-1,k);
  }
  void dfs(int cur,int par,int& k){
    ord[cur] = k++;
    low[cur] = ord[cur];
    used[cur] = 1;
    for(auto nxt:adj[cur]){
      if(used[nxt]==-1){
        dfs(nxt,cur,k);
        tree[cur].emplace_back(nxt);
        low[cur] = min(low[cur],low[nxt]);
      }
      else if(ord[nxt]<ord[cur]&&nxt!=par){
        low[cur] = min(low[cur],ord[nxt]);
      }
    }
  }
  vector<int> articulation_points(){
    // 関節点 := 頂点u,子vについて、ord[u] <= low[v] or 根の次数>1
    vector<int> res;
    if(tree[root].size()>1)res.emplace_back(root);
    for(int u=0;u<n;++u){
      if(u==root)continue;
      for(auto v:tree[u]){
        if(ord[u]<=low[v]){
          res.emplace_back(u);
          break;
        }
      }
    }
    return res;
  }
  void dump(){
    cout<<"idx : ";
    for(int i=0;i<n;++i)cout<<i<<(i+1<n?" ":"\n");
    cout<<"ord : ";
    for(int i=0;i<n;++i)cout<<ord[i]<<(i+1<n?" ":"\n");
    cout<<"low : ";
    for(int i=0;i<n;++i)cout<<low[i]<<(i+1<n?" ":"\n");
  }
};

signed main(){

  int n,m;
  cin>>n>>m;
  vector<vector<int>> adj(n);
  for(int i=0;i<m;++i){
    int u,v;cin>>u>>v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }

  lowlink g(adj,0);
  for(auto ans:g.articulation_points()){
    cout<<ans<<endl;
  }
  

}