# POJ 2411 Mondriaan's Dream （状压DP）

#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;
typedef __int64 LL;
const LL maxn = 12;

LL dp[maxn][1<<maxn];
int h,w;

bool check(int s,int t){
if(((s | t) + 1) >> w != 1) return false;
int tmp = s & t,cnt = 0;
while(tmp){
if(tmp & 1) cnt++;
else{
if(cnt % 2 == 1) return false;
cnt = 0;
}
tmp >>= 1;
}
if(cnt % 2 == 1) return false;
return true;
}

void solve(){
int Ed = 1 << w;
for(int j = 0 ;j < Ed; j++){
if(check(j,Ed - 1)) dp[0][j] = 1;
//cout<<dp[0][j]<<" ";
}
//cout<<endl;
for(int i=1;i<h;i++){
for(int j=0;j<Ed;j++){
for(int k=0;k<Ed;k++){
if(check(j,k)) {
dp[i][j] += dp[i-1][k];
//cout<<j<<" and "<<k<<endl;
}
}
//cout<<dp[i][j]<<" ";
}
//cout<<endl;
}
printf("%I64d\n",dp[h-1][Ed-1]);
}

int main(){
while(~scanf("%d%d",&h,&w)){
if(h + w == 0) break;
if(h < w) swap(h,w);
memset(dp,0,sizeof(dp));
solve();
}
return 0;
}


#### pku 2411 Mondriaan's Dream dp 状态压缩

2010-05-31 19:03:00

#### poj2411Mondriaan's Dream题解

2015-08-01 17:43:12

#### POJ2411:Mondriaan's Dream(状态压缩)

2014-05-04 22:44:33

#### POJ-2411-Mondriaan's Dream-轮廓线dp（插头dp）

2016-08-09 00:31:52

#### POJ2411——Mondriaan's Dream（轮廓线dp入门）

2016-08-03 20:12:01

#### poj 2411 Mondriaan's Dream(状态压缩dp)

2015-11-24 17:27:53

#### poj2411--Mondriaan's Dream(状压dp+dfs)

2015-02-04 20:49:28

#### POJ2411 状态压缩DP

2014-02-20 20:17:00

#### poj 2411 骨牌覆盖问题 状压dp

2016-02-27 00:04:25

#### POJ2411 - Mondriaan's Dream （状压DP+轮廓线DP）

2017-05-18 19:31:11