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>
#define pb push_back

using namespace std;
const int maxn = 110000;

int n, m, a, b;
vector <int> adj[maxn], cut;

bool mark[maxn];
int dp[maxn], h[maxn];
void dfs(int v)
{
    mark[v]=1;
    dp[v] = -1;
    bool p = 0;
    int t = max(0, h[v]-1), d = 0;
    for(auto u : adj[v])
    {
        if(!mark[u])
        {
            h[u] = h[v]+1, dfs(u);
            dp[v] = (dp[v]==-1 ? dp[u] : min(dp[v], dp[u]));
            d ++;
            if(dp[u] >= h[v])
                p = 1;
        }
        else
        {
            t = min(t, h[u]);
        }
    }
    if((v > 0 && p) || (v == 0 && d > 1))
        cut.pb(v);
    dp[v] = min((dp[v]==-1 ? t : dp[v]), t);
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m && cin>>a>>b; i ++)
        adj[a].pb(b), adj[b].pb(a);

    dfs(0);

    //for(int i = 0; i < n; i++)  cout << i << " : " << dp[i] << " , " << h[i] << endl;

    sort(cut.begin(), cut.end());
    for(auto v : cut)
        cout << v << endl;
    return 0;
}