随笔分类 -  DP—状态压缩dp

摘要:题目链接bc上的一道题,刚开始想用这个方法做的,因为刚刚做了一个类似的题,但是想到这只是bc的第二题,以为用bfs水一下就过去了,结果MLE了,因为bfs的队列里的状态太多了,耗内存太厉害。题意:从某一点出发,遍历网格上的一些点,每个点至少访问一次需要的最小时间是多少。官方题解:由于Harry的di... 阅读全文
posted @ 2014-10-20 11:17 水门 阅读(555) 评论(0) 推荐(0)
摘要:题目链接The input contains mutiple testcases. Please process till EOF.For each testcase, the first line contains two integers N (1 ≤ N ≤ 15), the side len... 阅读全文
posted @ 2014-10-17 20:59 水门 阅读(602) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1185思路:d[i][j][k]表示第i行的状态为第k个状态,第i-1行的状态为第j个状态的时候 的炮的数量。1表示放大炮, 地形状态中1表示山地。 1 #include 2 #include 3 #include 4 #includ... 阅读全文
posted @ 2014-03-07 21:14 水门 阅读(180) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=2411InputThe input contains several test cases. Each test case is made up of two integer numbers: the height h and the wi... 阅读全文
posted @ 2014-03-07 00:11 水门 阅读(185) 评论(0) 推荐(0)
摘要:这是做的第二道状态压缩dp题,又学习了…… 1 #include 2 #include 3 #define mo 10007 4 int dp[510][1>1; k=k>>1;22 }23 24 return 1;25 };26 27 int main()28 {29 int i,... 阅读全文
posted @ 2013-06-06 16:23 水门 阅读(199) 评论(0) 推荐(0)
摘要:看了好几回状态压缩dp了,也看 了不少博客,今天经过 贺贺的讲解对 位运算有了认识,参考了一下贺贺 的博客,终于做了第一道状态压缩dp题,还要努力( ⊙ o ⊙ )啊……状态压缩dp的一个很好的博客:http://blog.csdn.net/accry/article/details/6607703... 阅读全文
posted @ 2013-06-04 22:57 水门 阅读(194) 评论(0) 推荐(0)