裸地割点题。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=110;
int n;
int pre[maxn],low[maxn],bccno[maxn],iscut[maxn],bcc_cnt,dfs_clock;
vector<int> grid[maxn],bcc[maxn];
struct edge
{
int u,v;
edge(int a,int b):u(a),v(b){}
};
stack<edge> s;
int dfs(int u,int fa)
{
int lowu=pre[u]=++dfs_clock;
int child=0;
for(int i=0;i<grid[u].size();i++)
{
int v=grid[u][i];
edge e=edge(u,v);
if(!pre[v])
{
s.push(e);
child++;
int lowv=dfs(v,u);
lowu=min(lowu,lowv);
if(lowv>=pre[u])
{
iscut[u]=1;
bcc_cnt++;bcc[bcc_cnt].clear();
while(true)
{
edge x=s.top();s.pop();
if(bccno[x.u]!=bcc_cnt){bcc[bcc_cnt].push_back(x.u);bccno[x.u]=bcc_cnt;}
if(bccno[x.v]!=bcc_cnt){bcc[bcc_cnt].push_back(x.v);bccno[x.v]=bcc_cnt;}
if(x.u==u&&x.v==v)break;
}
}
}
else if(pre[v]<pre[u]&&v!=fa)
{
s.push(e);
lowu=min(lowu,pre[v]);
}
}
if(fa<0&&child==1)iscut[u]=0;
return lowu;
}
void find_bcc()
{
memset(pre,0,sizeof(pre));
memset(iscut,0,sizeof(iscut));
memset(bccno,0,sizeof(bccno));
bcc_cnt=dfs_clock=0;
for(int i=1;i<=n;i++)
{
if(!pre[i])dfs(i,-1);
}
}
int main()
{
freopen("in.txt","r",stdin);
int cas=1;
while(scanf("%d",&n)!=EOF,n)
{
string a;
for(int i=0;i<=n;i++)grid[i].clear();
a.clear();
while(getline(cin,a))
{
istringstream in(a);
int x,v=-1;
in>>v;
if(!v)break;
while(in>>x)
{
grid[v].push_back(x);
grid[x].push_back(v);
}
}
find_bcc();
int ans=0;
for(int i=1;i<=n;i++)
if(iscut[i])ans++;
printf("%d\n",ans);
}
return 0;
}