随笔分类 -  动态规划

摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4568思路:首先spfa预处理出每对宝藏之间的最短距离以及宝藏到边界的最短距离,然后dp[state][u]表示当前在点u,状态为state的最短距离,然后更新就行。#include #include #... 阅读全文
posted @ 2014-10-06 12:36 ihge2k 阅读(242) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4784思路:建图,对于同一个universe来说,就按题目给的条件相连,对于相邻的universe,连时间花费为1,费用为0的边,需要注意的是,对于起始点和终点只需在universe 0连边就可以了,对于... 阅读全文
posted @ 2014-10-05 20:41 ihge2k 阅读(224) 评论(0) 推荐(0)
摘要:题目链接:http://codeforces.com/contest/283/problem/B思路: dp[now][flag]表示现在在位置now,flag表示是接下来要做的步骤,然后根据题意记忆化搜索记忆,vis数组标记那些已经访问过的状态。#include #include #include... 阅读全文
posted @ 2014-05-29 17:01 ihge2k 阅读(159) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了。#include #include #include #include #define REP(i, a, ... 阅读全文
posted @ 2014-05-27 22:17 ihge2k 阅读(186) 评论(0) 推荐(0)