https://www.luogu.org/problem/P3388
Topic background
Split point
Title Description
Gives a NN n-point, mm without edges to FIG. M, seeking cut points of FIG.
Input Format
The first line of the input n-, Mn, m n- , m
Below mm m lines each input X, YX, Y X , Y represents XX X to YY Y there is an edge
Output Format
The first output line number cutpoint
The second line node according to an output node from small to large numbers, separated by space
A root node is not a search point x is the cut point, and only if = dfn [x] When there is at least one search tree low son x of y [y]>
#include<iostream> #include<cstdio> #define ri register int #define u int namespace opt { inline u in() { u x(0),f(1); char s(getchar()); while(s<'0'||s>'9') { if(s=='-') f=-1; s=getchar(); } while(s>='0'&&s<='9') { x=(x<<1)+(x<<3)+s-'0'; s=getchar(); } return x*f; } } using opt::in; #define NN 20005 #define MM 100005 #include<algorithm> namespace mainstay { u N,M,h[NN],cnt(1); struct node { u to,next; } a[MM<<1]; inline void add(const u &x,const u &y) { a[++cnt].to=y,a[cnt].next=h[x],h[x]=cnt; } u dfn[NN],low[NN],poi[NN],n,num; void tar(const u &x,const u &edg,const u &st) { dfn[x]=low[x]=++num; u _t(0); for(ri i(h[x]); i; i=a[i].next) { u _y(a[i].to); if((i^1)^edg) { if(!dfn[_y]) { tar(_y,i,st),low[x]=std::min(low[x],low[_y]); if(low[_y]>=dfn[x]) ++_t; } else low[x]=std::min(low[x],dfn[_y]); } } if(x^st) { if(_t) poi[++n]=x; } else if(_t>=2) poi[++n]=x; } inline void solve() { N=in(),M=in(); for(ri i(1); i<=M; ++i) { u _a(in()),_b(in()); add(_a,_b),add(_b,_a); } for(ri i(1); i<=N; ++i) { if(!dfn[i]) { tar(i,0,i); } } std::sort(poi+1,poi+n+1); printf("%d\n",n); for(ri i(1); i<=n; ++i) printf("%d ",poi[i]); } } int main() { //freopen("x.txt","r",stdin); mainstay::solve(); }