:https://www.luogu.org/problemnew/show/P3388
#include#include #include #include #include #include using namespace std;const int maxn = 100009;vector q,mp[maxn];int cnt,root,ind;int num[maxn],low[maxn],used[maxn];void dfs(int cur,int father){ ind++; num[cur]=low[cur]=ind; int child=0; for(int i=0;i =num[cur]) if(used[cur]==0)used[cur]=1,cnt++,q.push_back(cur); if(root==cur&&child==2) if(used[cur]==0)used[cur]=1,cnt++,q.push_back(cur); } else if(to!=father) { low[cur]=min(low[cur],num[to]); } }}int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { int u,v; scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u); } for(int i=1;i<=n;i++) { if(num[i]==0) //由于所有点不是全部连通的; ind=0,root=i,dfs(root,0); } sort(q.begin(),q.end()); printf("%d\n",cnt); for(int i=0;i