题意不懂啊。。。。。。
只知道求割点。
#includeusing namespace std;typedef long long LL;typedef unsigned long long ULL;typedef pair PII;const double eps=1e-5;const double pi=acos(-1.0);const int mod=1e9+7;const int INF=0x3f3f3f3f;const int N=1e4+10;const int M=2e4+10;struct Edge{ int to; int next;};Edge q[M*2];int head[M*2],tol,n,m;int dfn[N],low[N];int ind,top;bool flag[N],vis[N];void Tarjan(int u,int pre){ int v; int son=0; low[u]=dfn[u]=ind++; vis[u]=true; for(int i=head[u];i!=-1;i=q[i].next) { v=q[i].to; if(v==pre) continue; if(!dfn[v]) { son++; Tarjan(v,u); low[u]=min(low[v],low[u]); if(u!=pre&&low[v]>=dfn[u]) flag[u]=true; } else low[u]=min(low[u],dfn[v]); } if(pre==u&&son>1) flag[u]=true;}void init(){ tol=0; memset(head,-1,sizeof(head));}void add(int u,int v){ q[tol].to=v; q[tol].next=head[u]; head[u]=tol++;}int main(){ int T,cas=1;//freopen("D:\\in.txt","r",stdin); scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); init(); while(m--) { int u,v; scanf("%d%d",&u,&v); add(u,v); add(v,u); } memset(dfn,0,sizeof(dfn)); memset(low,0,sizeof(low)); memset(flag,0,sizeof(flag)); memset(vis,0,sizeof(vis)); ind=1; int ans=0; Tarjan(1,1); for(int i=1;i<=n;i++) if(flag[i]) { // printf("%d\n",i); ans++; } printf("Case %d: %d\n",cas++,ans); } return 0;}