Describe
One day, Gaofu Clj sent his friend Jzp a small toy.
This toy can be thought of as an n-point, without a heavy edge and a self-loop graph on the M-bar side. For each side, there are two states of Flash and darkness.
Jzp can set some edges to flash and some edges to be dark. When the JZP setting is complete, the toy calculates a score as follows. First, the flash edge and the N-dots are derived from the graph, and then the toy will find out the size of the largest Unicom component in the derived sub-graph, as a fractional output.
Jzp one day, he tried all the ways of setting the 2m side (flash or darkness on each side), and calculated the number of occurrences of each of these fractions. Written on a piece of paper.
But unfortunately, this piece of paper was lost by him one day. Now I'm telling you this diagram, can you help him recalculate the number of occurrences of each score?
Input
The first line is two numbers n (1<=n<=15) and M (0<=m<=n (n-1)/2), respectively, indicating the number of points and sides of the figure in the toy. Next m lines, two numbers a and b per line, indicate an edge between A and B.
The point starts with 1 marking.
Output
A total of n lines are output, and the first line indicates the number of occurrences of the fraction I, and the 10^9+7 is modeled.
Sample input
3 31 21) 32 3
Sample output
134
Mother does wjmzber the problem of the pear Alexander.
First, the conversion problem, set ans[k] means that all connected component size is <=k scheme.
The scheme of the maximum connected component K is converted into ans[k]-ans[k-1]
Then you can DP and consider slowly stripping the connected component from a set S. Set F[s] Represents the scenario in which the points in the collection S are allocated and meet the requirements.
Enumeration of the lowest bits of the element x is located in the collection S0, then f[s]= (| s|<=k?g[s]:0) +∑ (f[s0]*g[s0]| s0⊂s,| S0|<=k,{x}⊂s)
Where G[s] represents the number of scenarios in which the points in S are connected.
Calculate G[s] is that we can use the principle of repulsion, the point in S is connected to the number of schemes into the complete-s point is not connected to the number of programs. The S0 of the element x where the lowest bit of the S is enumerated is still calculated, and the calculation is done.
#include <cstdio>#include<cctype>#include<queue>#include<cmath>#include<cstring>#include<algorithm>#defineRep (i,s,t) for (int i=s;i<=t;i++)#defineDwn (i,s,t) for (int i=s;i>=t;i--)#defineren for (int i=first[x];i!=-1;i=next[i])using namespaceStd;inlineintRead () {intx=0, f=1;CharC=GetChar (); for(;! IsDigit (c); C=getchar ())if(c=='-') f=-1; for(; IsDigit (c); C=getchar ()) x=x*Ten+c-'0'; returnx*F;}Const intmaxn= -;Const intMod=1000000007; typedefLong Longll;intn,m,es[1<<maxn],u[maxn*maxn],v[maxn*maxn],cnt[1<<maxn];ll g[1<<maxn],f[1<<maxn],xp[maxn*MAXN],ANS[MAXN];intMain () {n=read (); m=read (); Rep (I,1, m) U[i]=read ()-1, V[i]=read ()-1; Rep (S,0,(1<<n)-1) {Rep (I,0, N-1)if(s& (1<<i)) cnt[s]++; Rep (I,1, m)if((s& (1<<u[i]) && (s& (1<<v[i])) es[s]++; } xp[0]=1; Rep (I,1, m) xp[i]= (xp[i-1]<<1)%MoD; g[0]=1; Rep (S,1,(1<<n)-1) { intbit=s&-R; for(intS0= (S-1) &S; S0; S0= (s0-1) &s)if(bit&S0) {(G[s]+=G[S0]*XP[ES[S^S0]])%=MoD; } G[s]= (xp[es[s]]-g[s]+mod)%MoD; } Rep (T,1, N) {f[0]=1; Rep (S,1,(1<<n)-1) {F[s]=cnt[s]<=t?g[s]:0;intbit=s&-S; for(intS0= (S-1) &S; S0; S0= (s0-1) &s)if((BIT&S0) &&cnt[s0]<=t) (F[s]+=f[s0^s]*g[s0])%=MoD; } Ans[t]=f[(1<<n)-1]; if(T) printf ("%lld\n", (ans[t]-ans[t-1]+MOD)%MoD); } return 0;}
View Code
#1071: Small Toys