Language: C++

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>

using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 100010

vector<int> G[MAX_N];
int n, m;
int num[MAX_N], par[MAX_N], low[MAX_N];
int cnt;

void dfs(int v, int prev){
	num[v] = low[v] = ++cnt;
	for (int i = 0; i < G[v].size(); i++){
		int nv = G[v][i];
		if (num[nv] == -1){
			par[nv] = v;
			dfs(nv, v);
			low[v] = min(low[v], low[nv]);
		}
		else if (nv != prev){
			low[v] = min(low[v], num[nv]);
		}
	}
}

vector<int> art_points(){
	memset(num, -1, sizeof(num));
	cnt = 0;
	dfs(0, -1);
	set<int> ap;
	int np = 0;
	for (int i = 1; i<n; i++){
		int p = par[i];
		if (p == 0)np++;
		else if (num[p] <= low[i])ap.insert(p);
	}
	if (np>1)ap.insert(0);
	vector<int> res;
	for (set<int>::iterator it = ap.begin(); it != ap.end(); it++)res.push_back(*it);
	return res;
}

int main(){
	cin.sync_with_stdio(false);
	cin >> n >> m;
	rep(i, m){
		int s, t;
		cin >> s >> t;
		G[s].pb(t); G[t].pb(s);
	}
	vector<int> a = art_points();
	rep(i, a.size())cout << a[i] << endl;
	return 0;
}





//#include <iostream>
//#include <queue>
//#include <vector>
//
//using namespace std;
//
//#define MAX 10000
//#define INFTY (1 << 30)
//
//
//class Edge
//{
//public:
//	int t, w;
//	Edge(){};
//	Edge(int _t, int _w):t(_t), w(_w){}
//};
//
//vector<Edge> G[MAX];
//int n, d[MAX];
//
//bool vis[MAX];
//int cnt;
//
//void bfs(int s)
//{
//	for (int i = 0; i < n; ++i)	d[i] = INFTY;
//
//	queue<int> Q;
//	Q.push(s);
//	d[s] = 0;
//	int u;
//	while (!Q.empty())
//	{
//		u = Q.front(); Q.pop();
//		for (int i = 0; i < G[u].size(); ++i)
//		{
//			Edge e = G[u][i];
//			if (d[e.t] == INFTY)
//			{
//				d[e.t] = d[u] + e.w;
//				Q.push(e.t);
//			}
//		}
//	}
//}
//
//void solve()
//{
//	bfs(0);
//	int maxv = 0;
//	int tgt = 0;
//	for (int i = 0; i < n; ++i)
//	{
//		if (d[i] == INFTY) continue;
//		if (maxv < d[i]){
//			maxv = d[i];
//			tgt = i;
//		}
//	}
//
//	bfs(tgt);
//	maxv = 0;
//	for (int i = 0; i < n; ++i)
//	{
//		if (d[i] == INFTY) continue;
//		maxv = max(maxv, d[i]);
//	}
//
//	cout << maxv << endl;
//}
//
//int main()
//{
//	int s, t, w;
//	cin >> n;
//
//	for (int i = 0; i < n - 1; ++i)
//	{
//		cin >> s >> t >> w;
//		G[s].push_back(Edge(t, w));
//		G[t].push_back(Edge(s, w));
//	}
//	solve();
//}
//

Compiler output:
a.cc: In function 'std::vector<int> art_points()':
a.cc:56:9: error: 'memset' was not declared in this scope
   56 |         memset(num, -1, sizeof(num));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <set>
  +++ |+#include <cstring>
    6 |