标签:while 正方形 std str 复杂度 string 奶牛 ++ iostream
#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 13
#define p 100000000
using namespace std;
int dp[maxn][1<<maxn],g[maxn];
int n,m;
inline int read(){
register int x(0),f(1); register char c(getchar());
while(c<'0'||'9'<c){ if(c=='-') f=-1; c=getchar(); }
while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int main(){
n=read(),m=read();
for(register int i=1;i<=n;i++){
for(register int j=0;j<m;j++) g[i]=(g[i]<<1)+read();
}
dp[0][0]=1;
for(register int i=1;i<=n;i++){
for(register int j=0;j<1<<m;j++) if((j&g[i])==j&&!((j&j<<1)||(j&j>>1))){
for(register int k=0;k<1<<m;k++){
if(!(k&j)) (dp[i][j]+=dp[i-1][k])%=p;
}
}
}
int ans=0;
for(register int i=0;i<(1<<m)-1;i++) (ans+=dp[n][i])%=p;
printf("%d\n",ans);
return 0;
}
[Usaco2006 Nov]Corn Fields牧场的安排
标签:while 正方形 std str 复杂度 string 奶牛 ++ iostream
原文地址:https://www.cnblogs.com/akura/p/10908317.html