Stick the board. Cut edges. Change > to >= to determine if u is a cut point.
#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;const int inf=0x3f3f3f3f ; const int Maxn=20008;const int maxm=100008;struct fuck{int u,v,next;bool ban;} Edge[maxm<<1];int tol;int head[maxn];void init () {Tol=0;memset (head,-1,sizeof (Head));} void Addedge (int u,int v) {edge[tol].u=u;edge[tol].v=v;edge[tol].next=head[u];edge[tol].ban=false;head[u]=tol++;} int tim=0;int pre[maxn],low[maxn];int tarj (int u,int fa) {int lowu=pre[u]=++tim;int child=0;int i,v,lowv;for (I=head[u]; I!=-1;i=edge[i].next) {v=edge[i].v;if (!pre[v]) {Child++;lowv=tarj (v,u); Lowu=min (LOWU,LOWV); if (Lowv>pre[u]) { Edge[i].ban=true;edge[i^1].ban=true;}} ElseIf (PRE[V]<PRE[U]&&V!=FA) lowu=min (Lowu,pre[v]);} Low[u]=lowu;return Lowu;} int Uni[maxn];bool vis[maxn];void DFS (int u,int idx) {int i,v;vis[u]=true;uni[u]=idx;for (I=head[u];i!=-1;i=edge[i]. Next) {if (edge[i].ban| | VIS[EDGE[I].V]) Continue;v=edge[i].v;dfs (V,IDX);}} int main () {int i,j,n,m,u,v;while (scanf ("%d%d", &n,&m) ==2) {iniT (); for (i=1;i<=m;i++) {scanf ("%d%d", &u,&v); Addedge (u,v); Addedge (v,u);} Tim=0;memset (pre,0,sizeof (PRE)), Tarj (1,-1), memset (vis,false,sizeof (VIS)), int ans=0;for (i=1;i<=n;i++) if (!vis[ I]) {DFS (i,i); ans++;} printf ("%d\n", ans), for (i=1;i<=n;i++) {if (i!=1) printf ("");p rintf ("%d", Uni[i]);} printf ("\ n");} return 0;}
#1184: Connectivity two • Double connected components of the edge