FatMouse and Cheese ————记忆化搜索

hdu 1078 fatmouse and cheese 记忆化搜索 FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2394 Accepted Submission(s): 913 Problem Description FatMouse has stor 阅读详情

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 cheese in a hole. Now he’s going to enjoy his favorite food.

FatMouse begins by standing at location (0,0). He eats up the cheese where he stands and then runs either horizontally or vertically to another location. The problem is that there is a super Cat named Top Killer sitting near his hole, so each time he can run at most k locations to get into the hole before being caught by Top Killer. What is worse – after eating up the cheese at one location, FatMouse gets fatter. So in order to gain enough energy for his next run, he has to run to a location which have more blocks of cheese than those that were at the current hole.

Given n, k, and the number of blocks of cheese at each grid location, compute the maximum amount of cheese FatMouse can eat before being unable to move.
Input
There are several test cases. Each test case consists of

a line containing two integers between 1 and 100: n and k
n lines, each with n numbers: the first line contains the number of blocks of cheese at locations (0,0) (0,1) … (0,n-1); the next line contains the number of blocks of cheese at locations (1,0), (1,1), … (1,n-1), and so on.
The input ends with a pair of -1’s.
Output
For each test case output in a line the single integer giving the number of blocks of cheese collected.
Sample Input
3 1
1 2 5
10 11 6
12 12 7
-1 -1
Sample Output
37


题意:
-老鼠在N∗NN∗N的棋盘上跳
-老鼠的起始位置是(0,0)(0,0)
-每次只能往棋盘上分值比较大的点跳,每跳到一个点就获得那个点对应的分值
-最多只能在行或者列上跳的距离是 k k

问老鼠能够获得的最大分值


#include<bits/stdc++.h>
using namespace std;
const int MAXN=107;
int a[MAXN][MAXN];
int dp[MAXN][MAXN];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int n,k;

bool check(int x,int y)
{
    if(x>=0&&x<n&&y>=0&&y<n)    return true;
    else    return false;
}
int dfs(int x,int y)
{
    if(dp[x][y])    return dp[x][y];
    int ans=0;
    for(int i=0;i<4;i++)
        for(int j=1;j<=k;j++)
        {
            int nx=x+j*dx[i];
            int ny=y+j*dy[i];
            if(check(nx,ny)&&a[x][y]<a[nx][ny])
                ans=max(ans,dfs(nx,ny));
        }
    dp[x][y]=ans+a[x][y];
    return dp[x][y];
}

int main()
{
    while(~scanf("%d %d",&n,&k))
    {
        if(n==-1&&k==-1)    break;
        memset(dp,0,sizeof(dp));
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                scanf("%d",&a[i][j]);
        cout<<dfs(0,0)<<endl;
    }
    return 0;
}


Oracle Scheduler任务故障诊断 实战指南 当基础环境无异常时,需聚焦任务本身的配置与状态。定义(JOB)→ 调度(SCHEDULE)→ 执行(SLAVE进程)→ 日志(LOG),每个环节都可能存在卡点。Oracle Scheduler任务的“隐性故障”看似棘手,实则是环境配置、资源竞争、时间逻辑等问题的集中体现。通过本文的诊断工具和排查思路,你可以构建从“基础环境→任务配置→执行链路→日志追踪”的全维度分析体系,让每一个“消失”的任务都无所遁形。 阅读详情

相关推荐

数据结构:五岔路口交通管理红绿灯设计

我们可以知道这是一个“图”的着色问题,首先要考虑,为什么可行路线是13条?当然可以通过穷举得出,如果用公式:则是: 或者 因为一条路线必须包括一出一进两个方向 第一种答案的解法: 一、固定E为入口,则有C_4^1=4的可能; 二、除去E(因为E只有一个入向),剩下ABCD四个路口,然后因为C只有一个出方向,所以从剩下 的ABD中选择一个入口,即C_3^1; 三、再从剩下的三个出口任选

潘猫猫的世界 1万+

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 ...

素璃的博客 475

全面解析:时延扩展与相干带宽、多普勒扩展与相干时间——无线通信基础

时延扩展与相干带宽 多径时延扩展与多径衰落 接收机所接收到的信号是通过不同的直射、反射、折射等路径到达接收机。由于电波通过各个路径的距离不同, 因而各条路径中发射波的到达时间不同,造成多径时延扩展。距离不同所以到达接收机的相位也不相同,不同相位的多个信号在接收端叠加, 如果同相叠加则会使信号幅度增强, 而反相叠加则会削弱信号幅度。 这样,接收信号的幅度将会发生急剧变化,就会产生多径衰落。 ...

king阿金 4万+

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 has hid between 0 an

weixin_54501632的博客 267

合宙Air780EP速连OneNET:AT+MQTT应用指南

本文详细讲解了合宙Air780EP使用AT指令通过MQTT接入OneNET的过程。

2401_82812461的博客 1389

realsense D455深度相机+YOLO V5结合实现目标检测(一)

realsense D455深度相机+YOLO V5结合实现目标检测代码来源环境配置代码分析:1.如何用realsense在python下面调用的问题:2.对main_debug.py文件的分析:结束语 可以实现将D435,D455深度相机和yolo v5结合到一起,在识别物体的同时,还能测到物体相对与相机的距离。 说明一下为什么需要做这个事情?1.首先为什么需要用到realsense D455深度相机? 因为他是普通的相机还加了一个红外测距的东西,所以其他二维图像一样,能够得到三维世界在二维像素平面的投影

文一生 3万+

DEV C++ 青少年信息学While未知次数循环

/带小数则,sum和i,以及1.0都是小数类型。while(sum<=X){ //不限次数,而是拿结果作比较来决定是否退出循环。求恰好使s=1+1/2+1/3+…+1/n的值大于X时n的值。(2<=x<=10)

ECHO_QS的博客 593

蠕虫病毒代码(纯属参考,请勿用于非法事件)

1.介绍蠕虫病毒 蠕虫病毒是一种常见的计算机病毒,是无须计算机使用者干预即可运行的独立程序,它通过不停的获得网络中存在漏洞的计算机上的部分或全部控制权来进行传播。 计算机病毒是指编制或者在计算机程序中插入的破坏计算机功能或者破坏数据和恶意篡改系统. 影响计算机使用并且能够自我复制的一组计算机指令或者程序代码 中文名:蠕虫病毒 传染方式:网络和电子邮件 外文名:Worm virus 类型:计算机病毒 2.代码(建议使用虚拟机,否则你的计算机将会就地报废,使用时要关闭电脑病毒保护,否则程序会...

Kenny20211105的博客 2万+

【HUSTOJ】1030: 恰好使s=1+1/2+1/3+…+1/n的值大于X时n的值

1030: 恰好使s=1+1/2+1/3+…+1/n的值大于X时n的值 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 71  Solved: 51 原题链接 Description 求恰好使s=1+1/2+1/3+…+1/n的值大于X时n的值。(2 Input 输入只有一行,包括1个整数X。 Output

cisordeng's space 4408

数据中心GPU芯片性能参数速查表(Nvidia+国产算力卡)

本文提供了一份数据中心GPU芯片性能参数速查表,涵盖Nvidia与国产算力卡两大阵营。文章详细解读了算力、显存、互连技术及功耗等关键性能指标,并对比了A100、H100、昇腾910B等主流型号,旨在帮助用户根据AI训练、推理等实际场景,做出高效的硬件选型与成本评估决策。

a0b1c2d3的专栏 836

概率论基础-严士健 第二版 习题与补充1.6答案

概率论基础-严士健 第二版 习题与补充1.6答案 1.不独立。 设有一均匀正八面体,其第1,2,3,4面染红色,第1,2,3,5面染白色,第1,6,7,8面染黑色,现在以A,B,C分别表示投一次正八面体出现红、白、黑的事件,则 P(A)=P(B)=P(C)=12.P(A) = P(B) = P(C) = \frac{1}{2}.P(A)=P(B)=P(C)=21​. P(ABC)=18=P(A)P...

weixin_42341993的博客 2515

HDU - 1078 FatMouse and Cheese

input: 3 1 1 2 5 10 11 6 12 12 7 -1 -1v    output: 37    题目大意: 一个n×n的矩阵,老鼠每次只能吃比上大的食物所在的区域,每次老鼠只能垂直或者水平移动[1,k]步,求老鼠最 多能吃多少食物。    分析: dp+dfs。跟滑雪有点类似,dp[i][j]=(...

DDDDDDDDDD4444444444的博客 218

【STK】手把手教你利用STK进行仿真-STK软件简介02 STK专业分析模块

STK/Astrogator是一个交互式轨道机动和深空探测计划工具,用于飞行器运行及任务分析,通过定义推力模型、目标星历、飞行器姿态,提供轨道机动的解决及优化方案。应用Astrogator分析轨道机动的可见性和地面站覆盖,用户可以快速、方便地进行全局分析。任务控制序列保存在STK场景中,用于任务运行、快速制定精确轨道机动方案。为在轨运行的飞行器制定或执行机动计划时,分析人员可以根据飞行过程数据,如发动机定标参数、实际初始轨道,计算出推进器点火和点火时机数据,用于发出指令及精炼机动计划。

weixin_44184852的博客 1864

FatMouse and Cheese 记忆化搜索模板

关于 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 ...

空与白的博客 189

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

记忆化搜索—— 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 lo...

naiue的博客 252

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

HDU - 1078 FatMouse and Cheese (记忆化搜索)

HDU - 1078 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 <

HHH_go_的博客 592

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

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 &lt;= p &lt; n and 0 &lt;= q &lt; n. At each grid lo...

- 回忆゛ 405

记忆化搜索 HDU FatMouse and Cheese

FatMouse and Cheese 题目大意:有只老鼠在一块n*n的土地的每一个坐标里都藏了食物,它最开始在左上角,他想尽可能吃多的食物,但是它下一次要去的坐标上的食物必须比当前坐标多才行,而且每次最多走k格。问这只大老鼠能吃掉最多多少食物。 dp[ i ][ j ]表示以 i , j 为起点能吃最多的食物(没有固定终点在哪里,注意到,如果(i,j)点的周围都比它小,那么(i,j)就是终点了)...

spicychicken的博客 193

FatMouse and Cheese (记忆化搜索)

HDU - 1078  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 &lt;= p &lt; n and 0 &lt;= q &lt; n. At...

qq_42759455的博客 244

P - 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 Fatmou

Irish_Moonshine的博客 307

HDU1078 FatMouse and Cheese 记忆化搜索

FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16459 Accepted Submission(s): 7010 Problem Description FatMouse has stor...

DouglasConnor的博客 312

hdoj1078 FatMouse and Cheese【记忆化搜索】

FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6235    Accepted Submission(s): 2528 Problem Description FatMou

走一步再走一步 846

hdoj 1078 fatmouse and cheese 记忆化搜索

FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5535    Accepted Submission(s): 2253 Problem Description FatMou

L影罗 422

HDU1078 ZOJ1107 FatMouse and Cheese【记忆化搜索】

FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15207 Accepted Submission(s): 6443 Problem Description FatMouse has stor...

海岛Blog 717

FatMouse and Cheese (记忆化搜索)

题目: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

王钰辉的博客 177

P - 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 gr...

aocan6909的博客 261
上一篇: Hex-a-bonacci ————记忆化搜索
下一篇: 滑雪 ————记忆化搜索
陶鸿杰
博客等级 码龄9年 93粉丝 298原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值