标签:ref mem pre define mes efi turn ace src
#include <bits/stdc++.h> # define LL long using namespace std; const int mod=100000000; int M, N; int grid[12]; LL dp[12][1<<12]; LL dfs(int r, int state){ if(r==M) return 1; if(dp[r][state]!=-1) return dp[r][state]; dp[r][state]=0; for(int i=0;i<(1<<N);++i){ if((i&(i<<1))>0 || (i&state)>0) continue; if((i&grid[r])!=i) continue; dp[r][state]+=dfs(r+1,i); dp[r][state]%=mod; } return dp[r][state]; } int main(){ scanf("%d %d", &M, &N); for(int i=0;i<M;++i){ for(int j=0;j<N;++j){ int a; scanf("%d", &a); if(a==1) grid[i]|=(1<<j); } } memset(dp,-1,sizeof(dp)); int res=dfs(0,0); printf("%d", res); return 0; }
P1879 [USACO06NOV]玉米田Corn Fields
标签:ref mem pre define mes efi turn ace src
原文地址:https://www.cnblogs.com/FEIIEF/p/12288900.html