poj 2411 Mondriaan's Dream_状态压缩dp】的更多相关文章

题意:给我们1*2的骨牌,问我们一个n*m的棋盘有多少种放满的方案. 思路: 状态压缩不懂看,http://blog.csdn.net/neng18/article/details/18425765 用1表示放置了骨牌,0表示没有放置.dp[i][j]表示第i行为状态j是有多少种方案. 分下面3种情况进行转移: d表示当前列号,s1 表示本行的状态,s2表示上一行的状态, 1 竖直放置   那么d=d+1,s1<<1|1 , s2<<1; 这是什么意思呢? 这表示上一行在d列没有放…
题目:http://poj.org/problem?id=2411 Input The input contains several test cases. Each test case is made up of two integer numbers: the height h and the width w of the large rectangle. Input is terminated by h=w=0. Otherwise, 1<=h,w<=11. Output For eac…
题目:id=2411" target="_blank">poj 2411 Mondriaan's Dream 题意:给出一个n*m的矩阵,让你用1*2的矩阵铺满,然后问你最多由多少种不同的方案. 分析:这是一个比較经典的题目.网上各种牛B写法一大堆.题解也是 我们能够定义状态:dp[i][st]:在第 i 行状态为 st 的时候的最慷慨案数. 然后转移方程:dp[i][st] = sum (dp[i-1][ss]) 即全部的当前行都是由上一行合法的状态转移而来. 而状态…
Description The CE digital company has built an Automatic Painting Machine (APM) to paint a flat board fully covered by adjacent non-overlapping rectangles of different sizes each with a predefined color. To color the board, the APM has access to a s…
Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6436   Accepted: 3470 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can affo…
题意: 一共有m个城市,城市之间有双向路连接,一个人有n张马车票,一张马车票只能走一条路,走一条路的时间为这条路的长度除以使用的马车票上规定的马车数,问这个人从a出发到b最少使用时间. 分析: 状态压缩dp,用dp[i][j]表示到达j城市的最小时间,其中i为剩余车票的集合.集合i使用状态压缩的表示方法.由于剩余车票的集合不断变小,实际上为求DAG最短路问题. 代码: #include<cstdio> #include<cmath> #include<iostream>…
Mondriaan's Dream Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15407   Accepted: 8889 Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series…
AC传送门:http://vjudge.net/problem/POJ-2411 [题目大意] 有一个W行H列的广场,需要用1*2小砖铺盖,小砖之间互相不能重叠,问有多少种不同的铺法? [题解] 对于每一行有w个位置,所以每一行都有0-2w-1种状态. 对于当前行的状态s,它是由前一行的状态s'转化过来的,显然,对于该行某个位置j: 如果前一行该位置为0,那么该位置可以竖放 即 0-> 1 如果前一行连续两个位置为0,那么这两个连续位置可以横放 即00-> 00 如果前一行该位置为1,显然该位…
题意:略. 思路:由于每个大炮射程为2,所以如果对每一行状态压缩的话,能对它造成影响的就是上面的两行. 这里用dp[row][state1][state2]表示第row行状态为state2,第row-1行状态为state1时最多可以安放多少大炮. 则递推公式为:dp[i][K][J] = max(dp[i-1][L][K] + num[J]).其中num[J]表示状态J的二进制形式里有多少个1. 代码我是参考的别人的,觉得写得很好. 主要有一下几个地方: 1. 在判断一个数二进制形式有多少个1时…
Description Bugs Integrated, Inc. is a major manufacturer of advanced memory chips. They are launching production of a new six terabyte Q-RAM chip. Each chip consists of six unit squares arranged in a form of a 2*3 rectangle. The way Q-RAM chips are…