The following:
Ming Ming has n a very beautiful beads and a number of different colors of the rope. Now Ming Ming wants to use a rope to connect all the beads into a whole.
All beads are now known to be different and numbered with integers 1 through n. For the first and J beads, you can choose to connect them without a rope, or by selecting one of the ci,j in a different color string. If the bead is viewed as a point, the rope is treated as an edge, and all the beads are connected together to form a connecting graph for all points. In particular, beads cannot be connected with themselves.
Ming-Ming wants to know how many different schemes are in place to connect all the beads into one whole. Because the answer can be very large, just output the answer to 1000000007 modulo results. The puzzle :
See count to consider to be dismissed. And in the case of how small n is.
If you do not need to connect then it is to SB question.
Preprocessing G[s] G[s] represents the number of scenarios at the selected state S.
Then let it be divided into two parts which are connected to a certain point.
Enumeration subset, so F[s]=g[s]−∑g[j]∗f[sxorj] F[s]=g[s]-\sum G[j]*f[s XOR J]
Code
#include <cstdio> #include <cstdlib> #include <cstring> #include <
Iostream> #define LL-long long using namespace std;
Const LL mod=1000000007;
LL n,g[66000],f[66000];
LL C[20][20];
void Pre (LL S) {g[s]=1; for (ll i=1;i<=n;i++) if ((1<< (i-1)), &s) for (ll j=i+1;j<=n;j++) if ((1<
< (j-1)) &s) (g[s]*= (c[i][j]+1))%=mod;
int main () {scanf ("%lld", &n);
for (ll i=1;i<=n;i++) for (ll j=1;j<=n;j++) scanf ("%lld", &c[i][j));
For (LL i=0;i< (1<<n); i++) pre (i); for (LL s=0; s< (1<<n); s++) {F[s]=g[s];
LL i=s^ (s&-s);
For (LL j=i;j;j= (j-1) &i) f[s]= (f[s]-g[j]*f[s^j]%mod+mod)%mod;
printf ("%lld", (f[(1<<n)-1])%mod); }