标签:mod include return amp clu 最小 情况 ace max
给出一个大小为\(n\)的无向图,求图中每个点的度数大于零且都是偶数的子图的个数。
\(n\leq2*10^5\)
#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;
}
标签:mod include return amp clu 最小 情况 ace max
原文地址:https://www.cnblogs.com/yanshannan/p/9426984.html