[Explanations] a labeled DAG count 1

[ HZOI, 2015] I count a labeled DAG

Set \ (F_i \) of \ (I \) the DAG view of the points (without Unicom)

Consider how to transfer due to a DAG must have at least a degree of the (0 \) \ point, so we handpicked a number of degree \ (0 \) point transfer.

Consider how to ensure there is no ring, complete a degree Imperial \ (0 \) after the points which waiting to be connected. There is still some points which they do not form a ring just fine, that is, sub-structure, access previous DP array just fine.
\ [{I \ choose j} 2 ^ {j \ times (ij)} dp_ {ij} \]

Such transfer is clearly duplication of programs, because of this count is destroyed by Imperial, the degree of \ (0 \) point may be more! (We unrestricted enumeration \ (j (ij) \) whether there are edges).

Consider a program there have been many times, distributed apparently appear like this:
\ [{i \ the Choose 1} + {i \ the Choose 2} + {i \ the Choose 3} \ DOTS \]
learn about [[explanations] HAOI2018] staining (NTT + inclusion and exclusion / binomial inversion) (how is you), directly multiplied by a \ ((--1) ^ \?) it out on inclusion and exclusion, try to find a \ ( (-1) ^ {j + 1 } \)

Transfer is:
\ [dp_i = \ sum_ {J =. 1} ^ I {I \ the Choose J} 2 ^ {J \ Times (ij of)} dp_ {ij of} (-. 1) ^ {J +. 1} \]
or study God Itst fairy undetermined coefficient method

Is an enumerated set of \ (0 \) number of points is the inclusion-exclusion coefficient of i \ (F_i \) , then the presence of a substantially \ (X \) a degree of a 0 point of DAG contribution was \ (\ SUM \ limits_. 1} ^ {X = I \ Binom {X} {I}. 1 F_i = \) , difficult to know from the binomial theorem \ (fi = (- 1) ^ {i- 1}\)

barley

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
 
 
using namespace std;  typedef long long ll;
inline int qr(){
      register int ret=0,f=0;
      register char c=getchar();
      while(c<48||c>57)f|=c==45,c=getchar();
      while(c>=48&&c<=57) ret=ret*10+c-48,c=getchar();
      return f?-ret:ret;
}
 
const int maxn=5e3+5;
const int mod=10007;
int c[maxn][maxn];
int dp[maxn];
int bin[maxn*maxn];
 
int main(){
      freopen("DAG.in","r",stdin);
      freopen("DAG.out","w",stdout);
      int n=qr();
      bin[0]=1;dp[0]=1;
      for(register int t=0;t<=n;++t){
        c[t][0]=1;
        for(register int i=1;i<=t;++i){
          c[t][i]=(c[t-1][i-1]+c[t-1][i])%mod;
        }
      }
      for(register int t=1;t<=n*n;++t) bin[t]=(bin[t-1]<<1)%mod;
      
      for(register int t=1;t<=n;++t){
        for(register int i=1,d;i<=t;++i){
          d=mod-c[t][i]*bin[i*(t-i)]%mod*dp[t-i]%mod;
          if(i&1) d=mod-d;
          dp[t]=(dp[t]+d)%mod;
        }
      }
      printf("%d\n",dp[n]);
      return 0;
}

Guess you like

Origin www.cnblogs.com/winlere/p/11258184.html