随笔分类 - 记忆化搜索
摘要:HDU4283You Are the One区间dp,记忆话搜索运行时间:#include #include #include using namespace std;const int maxn = 105,inf = 1 e)return 0; if(dp[s][e][k] != inf)return dp[s][e][k]; for(int i = s; i #include #include using namespace std;const int maxn =105;const int inf = 1#include #define Max(a,b) (a)>(b)?(...
阅读全文
摘要:记忆化搜索题目大意:老鼠出来后停在哪个格子就将那个格子里面的食物吃掉。每次出来都只能吃一方格的食物,每次出来最多跳过k个有食物的格子去吃另外那个格子里面的食物。思路:本题用记忆化搜索。其实就是记录在一个点上在之前搜索过程中的最大值,如果后来搜到了这没有大于这个值就停止搜索, 如果大于这更新这个最大值并继续搜索。题目源码如下:#include #include #include #include using namespace std;const int maxn = 110;int map[maxn][maxn],mark[maxn][maxn];int up[] = {0,0,1,-1};i
阅读全文

浙公网安备 33010602011771号