N*M矩阵,从F点出发,走完所有的Y点,每走一格花费1点电量,走到G点时,电量充满,D不可到达,问起始时的最小满电量可以走完所有Y,Y和G一共最多15个
先BFS出所有的F,Y,G之间的最短距离。
然后二分起始电量,对每个电量,做状压DP判断是否可行
#include "stdio.h"
#include "string.h"
#include "queue"
using names...
分类:
其他好文 时间:
2014-10-11 15:01:35
阅读次数:
166
也算是比较基础的状压dp了,跟做过的第二道比较又稍微复杂了一点需要记录之前两行的状态。。统计结果也稍有不同另外还学习了一个得到一个整数二进制位 1 的个数的位运算方法详见代码:#include #include #include#include#include#includeusing namesp...
分类:
其他好文 时间:
2014-10-10 22:47:26
阅读次数:
175
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=4628
Pieces
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1665 Accepted Submis...
分类:
其他好文 时间:
2014-10-10 17:48:24
阅读次数:
252
Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power ...
分类:
其他好文 时间:
2014-10-10 00:09:23
阅读次数:
206
第二个状压dp做过的第一个也是放牛问题,两头牛不能相邻这个题多了一个限制,就是有些位置不能放牛于是先与处理一下每一行所有不能放牛的状态,处理的过程直接对每一个不能放牛的状态或以下ac代码:#include #include #include#include#include#includeusing ...
分类:
其他好文 时间:
2014-10-09 23:16:31
阅读次数:
219
题目:ZOJ Problem Set - 2563 Long Dominoes
题意:给出1*3的小矩形,求覆盖m*n的矩阵的最多的不同的方法数?
分析:有一道题目是1 * 2的,比较火,链接:这里
这个差不多,就是当前行的状态对上一行有影响,对上上一行也有影响。所以
定义状态:dp【i】【now】【up】表示在第 i 行状态为now ,上一行状态为 up 时的方案数。
...
分类:
其他好文 时间:
2014-10-09 18:52:47
阅读次数:
159
题目:ZOJ Problem Set - 2297 Survival
题意:给出一些怪,有两个值,打他花费的血和可以增加的血,然后有一个boss,必须把小怪所有都打死之后才能打boss,血量小于0会死,也不能大于100.
分析:定义状态:dp【st】,表示在 st 状态下的血量。
然后转移:dp【st】 = max (dp【st】,dp【st&~(1
注意初始化的时候必须...
分类:
其他好文 时间:
2014-10-09 16:33:48
阅读次数:
366
Lights Against DudelyTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1415Accepted Submission(s): 4...
分类:
其他好文 时间:
2014-10-09 14:50:18
阅读次数:
140
Andrew Stankevich #21 G题,状压DP...
分类:
其他好文 时间:
2014-10-09 14:38:14
阅读次数:
144
LA 6560 - The Urge to Merge
题目链接
思路:状压dp,1表示要和下一个位置竖直乘,0表示不,这样递推下去即可
代码:
#include
#include
#include
using namespace std;
const int N = 1005;
const int INF = 0x3f3f3f3f;
int g[N][3], d...
分类:
其他好文 时间:
2014-10-07 23:44:04
阅读次数:
348