It is the horizontal and vertical put, the state is covered with 1, 0 means not covered.
1#include <iostream>2#include <vector>3#include <algorithm>4#include <string>5#include <string.h>6#include <stdio.h>7#include <queue>8#include <stack>9#include <map>Ten#include <Set> One#include <cmath> A#include <ctime> -#include <cassert> -#include <sstream> the using namespacestd; - - Const intn= -; - + Long Longdp[n][1<<N]; - + inth,w; A intRow; at voidDfsintColintPreintcur) { - if(col>=W) { -dp[row][cur]+=dp[row-1][pre]; - return; - } - if(col+1<=W) { inDFS (col+1,pre<<1|1,cur<<1);//No vertical dominoes currently in place -DFS (col+1,pre<<1,cur<<1|1);//put a vertical domino to cover the row with the upstream to } + if(col+2<=W) { -DFS (col+2,pre<<2|3,cur<<2|3);//Horizontal Play Dominoes the } * } $ intMain () {Panax Notoginseng while(SCANF ("%d%d", &h,&w)!=eof,h+W) { - if((H*W) &1) { thePuts"0"); + Continue; A } the if(h<w) swap (H,W);//Optimization of Complexity +Memset (DP,0,sizeofDP); -dp[0][(1<<W)-1]=1; $ for(row=1; row<=h;row++) { $Dfs0,0,0); - } -printf"%lld\n", dp[h][(1<<W)-1]); the } - return 0;Wuyi}
POJ 2411 State Compression pass, coverage scheme number