题目链接:https://www.luogu.org/problemnew/show/P3388
思路:割点模板题(在无向连通图中,如果将其中一个点以及所有连接该点的边去掉,图就不再连通,那么这个点就叫做割点)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%I64d",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define mod ll(1e9+7)
#define pb push_back
#define eps 1e-6
#define lc d<<1
#define rc d<<1|1
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
int n,vis[20008],low[20008],dfn[20008],m,x,y,ans,deep;
vector<int>g[20008];
void tarjan(int u,int rt)
{
dfn[u]=low[u]=++deep;
int tot=0;
for(int i=0;i<g[u].size();i++)
{
int v=g[u][i];
if(!dfn[v])
{
tarjan(v,rt);
low[u]=min(low[u],low[v]);
if(low[v]>=dfn[u]&&u!=rt) vis[u]=1;
if(u==rt) tot++;
}
low[u]=min(low[u],dfn[v]);
}
if(u==rt&&tot>=2) vis[rt]=1;
}
int main()
{
cin.tie(0);
cout.tie(0);
cin>>n>>m;
while(m--)
{
si(x),si(y);
g[x].pb(y);
g[y].pb(x);
}
FOR(i,1,n) if(!dfn[i]) tarjan(i,i);
FOR(i,1,n) if(vis[i]) ans++;
cout<<ans<<endl;
FOR(i,1,n) if(vis[i]) printf("%d ",i);
puts("");
return 0;
}