# poj2411 Mondriaan's Dream--状压dp

.

#define _CRT_SECURE_NO_DEPRECATE

#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<string>
#include<stdio.h>
#define INF 99999999
#define eps 0.0001
using namespace std;

int w, h;
int num;
long long dp[12][1 << 11];
int path[11 * (1 << 11)][2];

void dfs(int l, int now, int pre)
{
if (l > w)
return;
if (l == w)
{
path[num][0] = pre;
path[num++][1] = now;
return;
}

dfs(l + 2, (now << 2) | 3, (pre << 2) | 3);//横着放
dfs(l + 1, (now << 1) | 1, pre << 1);//竖着放
dfs(l + 1, now << 1, (pre << 1) | 1);//不放
}

int main()
{
while (~scanf("%d%d", &w, &h) && (w || h))
{
if (w*h % 2 == 1)
printf("0\n");
else
{
if (w > h)
swap(w, h);
num = 0;
dfs(0, 0, 0);//记住第一个参数是0，不是1，因为对于最后一列，如果是1，等到了w列，正好退出，只有0才会把w列考虑进去
memset(dp, 0, sizeof(dp));
dp[0][(1 << w) - 1] = 1;
for (int i = 0; i < h; i++)
for (int j = 0; j < num; j++)
dp[i + 1][path[j][1]] += dp[i][path[j][0]];
printf("%lld\n", dp[h][(1 << w) - 1]);

}
}
return 0;
}

#### poj2411Mondriaan's Dream题解

2015-08-01 17:43:12

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

2014-05-04 22:44:33

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

2015-02-04 20:49:28

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

2017-05-18 19:31:11

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

2016-08-09 00:31:52

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

2015-11-24 17:27:53

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

2016-08-03 20:12:01

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

2010-05-31 19:03:00

#### POJ 2411 铺地砖 状态压缩dp入门

2014-02-10 15:34:41

#### POJ2411 状态压缩DP

2014-02-20 20:17:00