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 REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
const int MAX=1e5;

vector< int > G[MAX];
int N;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev){
    prenum[current]=lowest[current]=timer;
    timer++;

    visited[current]=true;

    int next;

    REP(i,G[current].size()){
        next=G[current][i];
        if(!visited[next]){
            parent[next]=current;
            dfs(next,current);
            lowest[current]=min(lowest[current],lowest[next]);
        }else if(next!=prev){
            lowest[current]=min(lowest[current],prenum[next]);
        }
    }
}

void art_points(){
    REP(i,N) visited[i]=false;
    timer=1;
    dfs(0,-1);
    set< int > ap;
    int np=0;
    FOR(i,1,N){
        int p=parent[i];
        if(p==0) np++;
        else if(prenum[p]<=lowest[i]) ap.insert(p);
    }
    if(np>1) ap.insert(0);
    for(auto&& it:ap) printf("%d\n",it);
}

int main(){
    int m;
    scanf("%d%d",&N,&m);

    REP(i,m){
        int s,t;
        scanf("%d%d",&s,&t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();

    return 0;
}