@ysner
2018-08-05T12:13:17.000000Z
字数 1026
阅读 2689
结论
给出一个大小为的无向图,求图中每个点的度数大于零且都是偶数的子图的个数。
子图不一定是联通的!!!
则设图中最小环(不由其它环组成的环)的个数为。
如果同一联通块中的点再次联通,就构成了一个新的最小环。
因为这些环选与不选都可构成新子图,于是
(去掉一个环都不选的情况)。
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#define re register#define il inline#define ll long long#define max(a,b) ((a)>(b)?(a):(b))#define min(a,b) ((a)<(b)?(a):(b))#define fp(i,a,b) for(re int i=a;i<=b;i++)#define fq(i,a,b) for(re int i=a;i>=b;i--)using namespace std;const int mod=1e9+9,N=1e6+100;ll n,m,h[N],cnt,f[N],ans;il ll gi(){re ll x=0,t=1;re char ch=getchar();while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();if(ch=='-') t=-1,ch=getchar();while(ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();return x*t;}il int find(re int x){return x==f[x]?x:f[x]=find(f[x]);}int main(){freopen("magician.in","r",stdin);freopen("magician.out","w",stdout);n=gi();m=gi();fp(i,1,n) f[i]=i;fp(i,1,m){re int u=gi(),v=gi(),fu=find(u),fv=find(v);if(fu^fv) f[fu]=fv;else ans=(ans*2+1)%mod;printf("%lld\n",ans);}fclose(stdin);fclose(stdout);return 0;}
