#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,ans,x,y,clock,rt,low[300],dfn[300]; bool G[300][300]; void init(){ ans=clock=rt=0; memset(G,0,sizeof G); memset(dfn,0,sizeof dfn); memset(low,0,sizeof low); } void tarjan(int u){ dfn[u]=low[u]=++clock; bool flag=0; for (int v=1;v<=n;v++) if (G[u][v]){ if (!dfn[v]){ if (u==1) rt++; tarjan(v); low[u]=min(low[u],low[v]); if (low[v]>=dfn[u]) flag=1; } else low[u]=min(low[u],dfn[v]); } if (flag) ans++; } int main(){ while (scanf("%d",&n) && n){ init(); while (scanf("%d",&x) && x) while (getchar()!='\n'){ scanf("%d",&y); G[x][y]=G[y][x]=1; } tarjan(1); if (rt<=1) ans--; printf("%d\n",ans); } return 0; }
|