????????????
Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ??? M ??? 12; 1 ??? N ??? 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertile and can???t be planted. Canny FJ knows that the cows dislike eating close to each other, so when choosing which squares to plant, he avoids choosing squares that are adjacent; no two chosen squares share an edge. He has not yet made the final choice as to which squares to plant.
Being a very open-minded man, Farmer John wants to consider all possible options for how to choose the squares for planting. He is so open-minded that he considers choosing no squares as a valid option! Please help Farmer John determine the number of ways he can choose the squares to plant.
?????????John???????????????????????????????????????????????????????????????M???N???(1 ??? M ??? 12; 1 ??? N ??? 12)?????????????????????????????????????????????John?????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????John???????????????????????????????????????????????????????????????????????????????????????
John??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????
????????????????????????M???N?????????????????????
???2??????M+1??????????????????N??????????????????????????????????????????????????????????????????i+1???????????????i?????????????????????????????????0???1??????1??????????????????????????????????????????0???????????????????????????????????????
???????????????
????????????????????????????????????????????????100,000,000????????????
????????????
2 3
1 1 1
0 1 0
????????????
9
????????????
?????????????????????????????????????????????????????????
1??????????????????0????????????
dp[i][j]??????????????????i???
???i????????????j????????????????????????
???dp???????????????????????????
if(j?????? && k?????? && j,k?????????)
dp[i][j]+=dp[i-1][k];
?????????ans??????sigma (dp[n][j]) ?????? 0 <= j <= (1<< n)-1
????????????x?????????????????????
if( (( x&(x<<1) )==0) && (( x&(x>>1) )==0) ) return true;
else return false;
??????x?????????????????????
???x?????????????????????????????????1
??????/????????????????????????&??????????????????1,???????????????
(????????????????????????????????????????????????????????????????????????????????????????????????????????????==????????????????????????)
???????????????????????????????????????
bool check(int x)
{
if( x & (x<<1) ) return false;
if( x & (x>>1) ) return false;
return true;
}
???????????????????????????x???????????????????????????
????????????????????????f[i]?????????i??????????????????
???????????????1??????????????????0????????????
????????????????????????x????????????????????????
if((j&f[i])==0 )return true;
else return false;
???????????????????????????????????????????????????
?????????????????????????????????????????????0
???????????????x?????????????????????????????????(?????????1)
????????????????????????1
?????????????????????dp?????????
********************************
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
using namespace std;
int read()
{
int f=1,x=0;
char ss=getchar();
while(ss<???0???||ss>???9???){if(ss==???-???)f=-1;ss=getchar();}
while(ss>=???0???&&ss<=???9???){x=x*10+ss-???0???;ss=getchar();}
return f*x;
}
const int mod=1e8;
int m,n;
int f[110];
int dp[50][10010];
int ans;
bool check(int x)
{
if( (( x&(x<<1) )==0) && (( x&(x>>1) )==0) ) return true;
else return false;
}
int main()
{
m=read();n=read();
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
{
int k=read();
f[i]=(f[i]<<1)+(k^1);
}//??????????????????
for(int i=0;i<=(1<<n)-1;i++)
if( check(i) && (i&f[1])==0 ) dp[1][i]=1;
//??????????????????????????????
for(int i=2;i<=m;i++)//?????????????????????????????????
{
for(int j=0;j<=(1<<n)-1;j++)//?????????i????????????
{
if( check(j) && (j&f[i])==0 )//????????????????????????
for(int k=0;k<=(1<<n)-1;k++)//?????????i-1????????????
if((j&k)==0) dp[i][j]+=dp[i-1][k]%mod,dp[i][j]%=mod;
//??????????????????dp??????
}
}
for(int i=0;i<=(1<<n)-1;i++)
ans+=dp[m][i]%mod,ans%=mod;
cout<<ans;
return 0;
}