/*Good magic ... I mean, there's a lot to be learned. Note that n<=9 is not a search or a search + pruning 70 points enumeration put or not put here with the shape of the AH F[i][j][k] means the first I row put J King I row state is K of the scheme number of the transfer words enumeration the state of the lower level to calculate the state there are several kings and then update complexity 2^n*2^n*n*k*n the last n is the king number this can be pre-treatment to get out there is a problem is the problem of mutual harm first in the same row adjacent to the left to move to the right to move a bit better incidentally handle two states can transfer the last σf[n][k][i]*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 520using namespacestd;intN,K,V1[MAXN],V2[MAXN][MAXN],CNT[MAXN];Long Longans,f[Ten][ -][MAXN];voidget_v () { for(intI=0;i< (1<<N); i++) if((i& (i>>1))==0) {V1[i]=1;intC=0; for(intj=i;j;j>>=1) c+=j&1; Cnt[i]=C; } for(intI=0;i< (1<<n); i++)if(V1[i]) for(intj=0;j< (1<<n); j + +)if(V1[j])if((i&j) = =0&& (i& (j>>1))==0&& (j& (i>>1))==0) V2[i][j]=1;}intMain () {CIN>>n>>J; Get_v (); for(intI=0;i< (1<<N); i++) f[1][cnt[i]][i]=1; for(intI=2; i<=n;i++) for(intj=0;j< (1<<n); j + +)if(V1[j]) for(intk=0;k< (1<<n); k++)if(V2[j][k]) for(intr=cnt[j];r+cnt[k]<=k;r++) F[i][r+cnt[k]][k]+=f[i-1][r][j]; for(intI=0;i< (1<<N); i++) ans+=F[n][k][i]; cout<<ans<<Endl; return 0;}
Codevs 2451 Non-invasive (like ya DP)