#include <iostream>
#include <vector>
using namespace std;
int n, r, cnt, result;
#define MAXN 1010
vector<int> map[MAXN];
int low[MAXN], pre[MAXN], degree[MAXN];
void dfs( int w, int parent )
{
pre[w]= cnt++; low[w]= pre[w];
for( size_t i= 0; i< map[w].size(); ++i )
{
int v= map[w][i];
if( pre[v]== 0 )
{
dfs(v,w);
if( low[w]> low[v] ) low[w]= low[v] ;
}
else if( low[w]> pre[v] && v!= parent ) low[w]= pre[v];
}
}
int main()
{
while( scanf("%d%d",&n,&r)!= EOF )
{
for( int i= 0; i<= n; ++i ) map[i].clear();
for( int i= 0; i< r; ++i )
{
int a, b;
scanf("%d%d",&a,&b);
map[a].push_back(b);
map[b].push_back(a);
}
memset( pre, 0, sizeof(pre) );
memset( low, 0, sizeof(low) );
memset( degree, 0, sizeof(degree) );
cnt= 1; result= 0;
dfs(1,0);
for( int i= 1; i<= n; ++i )
for( int j= 0; j< map[i].size(); ++j )
if( low[i]!= low[ map[i][j] ] ) degree[ low[i] ]++;
for( int i= 1; i<= n; ++i )
if( degree[i]== 1 ) result++;
printf("%d\n", (result+ 1)/ 2 );
}
return 0;
}
posted on 2009-02-23 22:12
Darren 阅读(262)
评论(0) 编辑 收藏 引用