FatMouse and Cheese】的更多相关文章

FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8610    Accepted Submission(s): 3611 Problem Description FatMouse has stored some cheese in a city. The city can be considere…
pid=1078">FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4811    Accepted Submission(s): 1945 Problem Description FatMouse has stored some cheese in a city. The city can…
FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7576    Accepted Submission(s): 3133 Problem Description FatMouse has stored some cheese in a city. The city can be considered…
FatMouse and Cheese Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is la…
题目大意:   给n*n地图,老鼠初始位置在(0,0),它每次行走要么横着走要么竖着走,每次最多可以走出k个单位长度,且落脚点的权值必须比上一个落脚点的权值大,求最终可以获得的最大权值   (题目很容易会理解错题意,道友小心) #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace…
FatMouse and Cheese Problem Description FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse…
HDU 1078 FatMouse and Cheese ( DP, DFS) 题目大意 给定一个 n * n 的矩阵, 矩阵的每个格子里都有一个值. 每次水平或垂直可以走 [1, k] 步, 从 (0, 0) 点开始, 下一步的值必须比现在的值大. 问所能得到的最大值. 解题思路 一般的题目只允许 向下 或者 向右 走, 而这个题允许走四个方向, 所以状态转移方程为 dp(x, y) = dp(nextX, nextY) + arr(x, y); dp 代表在 x, y 的最大值. 由于 下一…
FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14253    Accepted Submission(s): 6035 Problem Description FatMouse has stored some cheese in a city. The city can be considere…
FatMouse and Cheese FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid between 0 a…
FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4966    Accepted Submission(s): 2035 Problem Description FatMouse has stored some cheese in a city. The city can be considere…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5701    Accepted Submission(s): 2320 Problem Description FatMouse has stored some cheese in a city. The city can be considered as a square grid of…
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid between 0 and 100 blocks of che…
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid between 0 and 100 blocks of che…
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1078" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=1078 Problem Description FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension…
原题链接 题目大意:FM在一个街道n*n街道的(0,0)点,在每个网格里放着cheese,他要尽可能多的吃这些cheese.有两个规则:1)他跑的总距离不能超过k步:2)下一个节点的cheese的块数必须超过这个节点. 解法:题目是去年秋天做的,现在看了下貌似就是用一下广搜,从原点开始一个个查找.我直接把当时的代码贴过来了,看看当时写的注释,发现暑假都过了一半了,算法都没有总结好.惭愧了. 参考代码: #include<string.h> using namespace std; int n,…
题意:FatMouse在一个N*N方格上找吃的,每一个点(x,y)有一些吃的,FatMouse从(0,0)的出发去找吃的.每次最多走k步,他走过的位置能够吃掉吃的.保证吃的数量在0-100.规定他仅仅能水平或者垂直走,每走一步.下一步吃的数量须要大于此刻所在位置,问FatMouse最多能够吃多少东西. 须要对步数进行扩展. #include<iostream> using namespace std; #define N 101 #define max(a,b) ((a)>(b)?(a)…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1107 http://acm.hdu.edu.cn/showproblem.php?pid=1078 1.从gird[0][0]出发,每次的方向搜索一下,每次步数搜索一下 ; i<; i++) { ; j<=k; j++) { ]*j; ]*j; &&tx<n&&ty>=&&ty<n&&a…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1078 题目大意: 题目中的k表示横向或者竖直最多可曾经进的距离,不可以拐弯.老鼠的出发点是(1,1). 对于老鼠从当前点可以到达的点.筛选出从这些点到达当前点所能获得的cheese的最大值. 思路:记忆化搜索. 假设对于当前的点.没有被搜索过(dp[i][j]=0).那么就对其进行搜索.搜索过程中记录下最优的解. 假设已经被搜索过了,就能够直接利用已经记录的值来进行推断 了,不须要再去搜索. 假设…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意:给出n, k,然后给出n*n的地图,(下标0~n-1),有一只老鼠从(0,0)处出发,只能走直线,并且目标点的数值比当前点要大.每次最长可以走k步,问最长的一条链的数值和. 用一个二维数组dp(i,j)表示某一格出发的时候最长链的数值和,然后dfs. #include <algorithm> #include <iostream> #include <iomanip&…
题意:给出n*n的二维矩阵,和k,老鼠每次最多走k步,问老鼠从起点(0,0)出发,能够得到的最大的数(即为将每走过一点的数都加起来的和最大)是多少 和上一题滑雪一样,搜索的方向再加一个循环 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<algorithm> using namespace std; typedef long long…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1078 老鼠初始时在n*n的矩阵的(0 , 0)位置,每次可以向垂直或水平的一个方向移动1到k格,每次移动过去的那个格子里面的数值必须比当前所在格子里面的大,求出路径上所有数值总和最大值. 直接上代码: #include <iostream> #include <cstring> #include <cstdio> using namespace std; ][] , dp[…
直接爆搜肯定超时,除非你加了某种凡人不能想出来的剪枝...555 因为老鼠的路径上的点满足是递增的,所以满足一定的拓补关系,可以利用动态规划求解 但是复杂的拓补关系无法简单的用循环实现,所以直接采取记忆化搜索的方式进行DP,成功避免重叠子问题,避免超时 #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include…
详见代码 #include <iostream> #include <cstdio> #include <cstdlib> #include <memory.h> using namespace std; const int inf=0x3f3f3f3f; ][]; ][];//表示到i,j的最大路径和 ][]= {,,-,,,,,-}; int n,m; int dfs(int x,int y) { ; if(!dp[x][y]) { ; i<=m;…
这道题目是典型的DFS+记忆化搜索, DP思想.符合:含重叠子问题,无后效性等特点. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 105 int dp[MAXN][MAXN]; int a[MAXN][MAXN]; int n, k; int max(int a, int b) { return a>b ? a:b; } int dfs(int x, int y) { i…
只能横向或竖向走...一次横着竖着最多k步...不能转弯的.... 为毛我的500+ms才跑出来... #include<cstdio> #include<iostream> #include<algorithm> using namespace std; int mp[105][105],n,k; int dp[105][105]; int dx[105][4]={{0,0,0,0},{-1,1,0,0}}; int dy[105][4]={{0,0,0,0},{0,…
这是一道记忆化搜索,也就是有记录的搜索. 注意点:一次走k步不能拐弯 int bfs(int x,int y) { ; ) return ans[x][y]; ;i<;i++) { ;j<=k;j++) { int tx=x+j*dx[i]; int ty=y+j*dy[i]; if(!in(tx,ty)||g[tx][ty]<=g[x][y]) continue; int res=bfs(tx,ty); mm=max(res,mm); } } return ans[x][y]=mm+g…
题目链接:点击链接 题目大意:老鼠从(0,0)出发,每次在同一个方向上最多前进k步,且每次到达的位置上的数字都要比上一个位置上的数字大,求老鼠经过的位置上的数字的和的最大值 #include<stdio.h> #include<string.h> #define max(a,b) a>b?a:b int n; int k;//前进的步数 int map[105][105]; int ans[105][105];//记忆化搜索,保存中间搜索结果 int search(int x…
最近一直在写dp,然后别的就啥也不管了(wtcl),很明显的最简单的搜索题竟然卡了,一开始的思路是每一个格子都只能是从四周的格子转化过来的,只要找到四周最大的那个那么dp[i][j]=max+a[i][j],但是无法确定四周的状态,不知道i,j该怎么开始,所以就卡了,竟然不往搜索上去想,emmmm,希望记住一下,看cls的ppt,说刷1000道poj的傻逼题还是个傻逼,但是现在连傻逼题都写不出来. #include <iostream> #include <cstring> #in…
http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意: 一张n*n的格子表格,每个格子里有个数,每次能够水平或竖直走k个格子,允许上下左右走,每次走的格子上的数必须比上一个走的格子的数大,问最大的路径和. 记忆化搜索 #include <iostream> #include <string.h> #include <stdio.h> using namespace std; ][] = { {, },{ -, }, {, }…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意:每次仅仅能走 横着或竖着的 1~k 个格子.求最多能吃到的奶酪. 代码: #include <stdio.h> #include <ctime> #include <math.h> #include <limits.h> #include <complex> #include <string> #include <fun…