#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using PII = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
int n,m;
int f[20][1<<13];
int mp[110];
int cnt[1<<13];
const int mod = 100000000;
bool check(int x){
//当前状态没有相邻的1
if(!(x & x>>1)){
return true;
}
return false;
}
int ff(int x,int y){
while(x && y){
if((x & 1) == 1 && (y & 1) == 1) return 0;
x = x>>1;
y = y>>1;
}
return 1;
}
int grass_st(int grass ,int st){
while(grass || st){
if((grass & 1) ==0 && (st & 1) == 1) return 0;
grass = grass >>1;
st = st>>1;
}
return 1;
}
int main(){
cin>>m>>n;
for(int i=1;i<=m;i++){
int st = 0;
for(int j=0;j<n;j++){
int x;
cin>>x;
if(x) st |= (1<<j);
}
mp[i] = st;
}
mp[m+1] = 0;
VI state;
for(int i=0;i<=(1<<n)-1;i++){
if(check((i))) state.push_back(i);
}
VI head[1<<13];
for(auto x :state){
for(auto y : state){
if(ff(x,y)) {
head[x].push_back(y);
//cout << x << " " << y << endl;
}
}
}
VI grass[1<<13];
for(int i=1;i<=m+1;i++){
for(auto y : state){
if(grass_st(mp[i],y)){
grass[i].push_back(y);
//cout<<y<<" ";
}
}
//cout<<endl;
}
memset(f,0,sizeof f);
f[0][0] = 1;
for(int i=1;i<=m+1;i++){
for(auto x : grass[i])
{
{
for(auto y : head[x])
{
f[i][x] = (f[i-1][y] + f[i][x]) % mod;
}
}
}
}
cout<<f[m+1][0] % mod;
}
感觉思维上好像难度不大,主要就是这个预处理合理状态得仔细想想