"UVa" Tiling Dominoes

Source: Internet
Author: User

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem= 2245

Test instructions: The number of programs that use a 1x2 piece to fill the NXM board. (nxm<=100)

#include <bits/stdc++.h>using namespace Std;long long d[2][1<<10], N, m;int main () {while (~scanf ("%d%d", & Amp;n, &m)) {if (m>n) swap (M, n), int now=0, last=1, all= (1<<m)-1, up=1<< (m-1); for (int i=0; i<=all; + +i) d[last][i]=0;d[last][all]=1;for (int i=1; i<=n; ++i) for (int. j=1; j<=m; ++j) {for (int s=0; s<=all; ++s) D[now] [S]=0;for (int s=0; s<=all; ++s) if (D[last][s]) {int goal= (s<<1) &all;if (i!=1 &&!) ( S&up) d[now][goal|1]+=d[last][s];if (j!=1 &&!) ( s&1) && (s&up)) d[now][goal|3]+=d[last][s];if (s&up) d[now][goal]+=d[last][s];} Swap (now, last);} printf ("%lld\n", D[last][all]);} return 0;}

  

Classic question .... Contour Line DP ... Set the status of each lattice, then record the status of the above contour lines, then consider three kinds of transfer:

1, this lattice is not covered, the current grid does not cover

2, this lattice is not covered, with a piece of pieces covering the top and the current point

3. There is no overlay on the left side of this lattice and overlay on the top, with a piece of pawn covering the left and the current point

Then notice open long long ...

"UVa" Tiling Dominoes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.