题目链接 题目描述:哈密尔顿路问题.n个点,每一个点有权值,设哈密尔顿路为 C1C2...Cn,Ci的权值为Vi,一条哈密尔顿路的值分为三部分计算: 1.每一个点的权值之和 2.对于图中的每一条CiCi+1,加上Vi*Vi+1 3.对于路径中的连续三个点:CiCi+1Ci+2,若在图中,三点构成三角形,则要加上Vi*Vi+1*Vi+2 求一条汉密尔顿路可以获得的最大值,并且还要输出有多少条这样的哈密尔顿路. 这道题的状态感觉不是很难想,因为根据一般的哈密尔顿路问题,首先想到的是设计二维状态,dp…
题目:http://poj.org/problem?id=2288 不知为什么记忆化搜索就是WA得不得了! #include<iostream> #include<cstdio> #include<cstring> #define ll long long using namespace std; ,Lm=(<<)+; int q,n,m,lm,v[N]; ll ans,prn,dp[Lm][N][N],f[Lm][N][N]; bool b[N][N];…
poj - 3254 - Corn Fields (状态压缩)超详细 参考了 @外出散步 的博客,在此基础上增加了说明 题意: 农夫有一块地,被划分为m行n列大小相等的格子,其中一些格子是可以放牧的(用1标记),农夫可以在这些格子里放牛,其他格子则不能放牛(用0标记),并且要求不可以使相邻格子都有牛.现在输入数据给出这块地的大小及可否放牧的情况,求该农夫有多少种放牧方案可以选择(注意:任何格子都不放也是一种选择,不要忘记考虑! 思路: 在样例中是一个2×3的表格,我们可以用数字的二进制来枚举每一…
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…
题目传送门:http://poj.org/problem?id=1632 Vase collection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2308   Accepted: 901 Description Mr Cheng is a collector of old Chinese porcelain, more specifically late 15th century Feng dynasty vase…
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…
题意:给我们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列没有放…
一道状态压缩的题,错了好多次....应该先把满足的情况预处理出来 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int fitnum,n,m; ],state[<<]; ][<<]; #define mod 1000000000 int main() { while(~scanf("%d%d",&n,&m))…
推荐网址,下面是别人的解题报告: http://www.cnblogs.com/chasetheexcellence/archive/2012/04/16/poj2441.html 里面有状态压缩论文的链接,可以看看. 该解题报告中用的是二维数组,但是很显然的是,递推式中的下一行只与上一行有关,类似于最长公共子序列,可以用滚动数组,在滚动数组后发现只用一个数组就可以了.至于是不是要和0-1背包一样得按从大到小的顺序,我没有,我的状态是从小到大的顺序,但是也AC了. 如果不用滚动数组,会超内存.…
Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 p…