Po姐的说法
任选一棵生成树,考虑选择树边或者非树边
定义一条非树边为好边当且仅当两个端点在树上的距离为奇数,否则为坏边
如果坏边只有一条那么这条坏边是可选的
如果一条树边被所有的坏边覆盖而且不被好边覆盖那么这条边是可选的
按照自己的理解 就是在所有奇环上 不在任何偶环上的边
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> abcd;
inline char nc()
{
static char buf[100000],*p1=buf,*p2=buf;
if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
return *p1++;
}
inline void read(int &x)
{
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=200005;
struct edge{
int u,v,next;
};
edge G[N<<1];
int head[N],inum=1;
inline void add(int u,int v,int p){
G[p].u=u; G[p].v=v; G[p].next=head[u]; head[u]=p;
}
int n,m,ans;
int depth[N],fat[N],vst[N];
int ecnt,ocnt,even[N],odd[N];
#define V G[p].v
void dfs(int u,int fa,int lastp)
{
vst[u]=1; fat[u]=fa; depth[u]=depth[fa]+1;
for (int p=head[u];p;p=G[p].next)
if (p!=(lastp^1))
if(!vst[V])
dfs(V,u,p),even[u]+=even[V],odd[u]+=odd[V];
else
{
if(depth[V]>depth[u])
continue;
if((depth[u]-depth[V])&1)
even[u]++,even[V]--,ecnt++;
else
odd[u]++,odd[V]--,ocnt++;
}
}
int main()
{
freopen("t.in","r",stdin);
// freopen("t.out","w",stdout);
int u,v;
read(n); read(m);
for(int i=1;i<=m;i++)
read(u),read(v),add(u,v,++inum),add(v,u,++inum);
for(int i=1;i<=n;i++)
if(!vst[i])
dfs(i,0,0);
for(int i=1;i<=n;i++)
if(fat[i] && odd[i]==ocnt && !even[i])
ans++;
if(ocnt==1) ans++;
printf("%d\n",ans);
return 0;
}