题目链接

bzoj3628: [JLOI2014]天天酷跑

题解

开始读错题目了,尴尬

由于题目说的跳跃次数和高度是在一开始设定的。

发现枚举一下记忆化搜索就可以过了

要注意,跳到最高点是可以不下坠继续连跳的

另外,上边界不能到达

代码

#include<cstdio>
#include<cstring>
#include<algorithm>
inline int read() {
int x = 0,f = 1;
char c = getchar();
while(c < '0' || c > '9'){if(c == '-') f = -1; c = getchar(); }
while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = getchar();
return x * f;
}
const int maxn = 100007;
int n,m,c1,c2,h,freq;
#define INF 100000007
int a[23][maxn];
int f[23][maxn][6];
bool vis[23][maxn][6];
int dfs(int x,int y,int jumpcnt) {
if(y > n) return 0;
if(a[x][y] == -1) return -INF;
if(vis[x][y][jumpcnt]) return f[x][y][jumpcnt];
if(x == 1)jumpcnt = 0;
int tmp = -INF ;
if(jumpcnt < freq) {
int Sum = 0,tx = x,ty = y; bool can = true;
for(int i = 1;i < h;i ++) {
tx ++,ty ++;
if(a[tx][ty] == -1) {can = false; break; } Sum += a[tx][ty];
}
if(can) tmp = std::max(tmp,Sum + dfs(tx + 1,ty + 1,jumpcnt + 1));
}
if(x == 1) tmp = std::max(tmp, dfs(x,y + 1,0)) ;
if(x > 1) tmp = std::max(tmp, dfs(x - 1,y + 1,jumpcnt));
f[x][y][jumpcnt] = tmp + a[x][y];
vis[x][y][jumpcnt] = true;
return f[x][y][jumpcnt];
}
int ans = -INF ,an1,an2;
int main() {
n = read(),m = read(), c1 = read(),c2 = read();
for(int i = 1;i <= m;++ i) for(int j = 1;j <= n;++ j)
a[i][j] = read();
for(freq = 1;freq <= 5;++ freq)
for(h = 1;h * freq < m;++ h) {
memset(vis,0,sizeof vis);
memset(f,0,sizeof f);
int sum = dfs(1,0,m) - (h - 1) * c1 - (freq - 1) * c2;
if(sum > ans) ans = sum , an1 = h, an2 = freq;
}
if(ans > 0) printf("%d %d %d\n",ans,an2,an1);
else puts("mission failed");
return 0 ;
} #include<cstdio>
#include<cstring>
#include<algorithm>
inline int read() {
int x = 0,f = 1;
char c = getchar();
while(c < '0' || c > '9'){if(c == '-') f = -1; c = getchar(); }
while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = getchar();
return x * f;
}
const int maxn = 100007;
int n,m,c1,c2,h,freq;
#define INF 100000007
int a[23][maxn];
int f[23][maxn][6];
bool vis[23][maxn][6];
int dfs(int x,int y,int jumpcnt) {
if(y > n) return 0;
if(a[x][y] == -1) return -INF;
if(vis[x][y][jumpcnt]) return f[x][y][jumpcnt];
if(x == 1)jumpcnt = 0;
int tmp = -INF ;
if(jumpcnt < freq) {
int Sum = 0,tx = x,ty = y; bool can = true;
for(int i = 1;i < h;i ++) {
tx ++,ty ++;
if(a[tx][ty] == -1) {can = false; break; } Sum += a[tx][ty];
}
if(can) tmp = std::max(tmp,Sum + dfs(tx + 1,ty + 1,jumpcnt + 1));
}
if(x == 1) tmp = std::max(tmp, dfs(x,y + 1,0)) ;
if(x > 1) tmp = std::max(tmp, dfs(x - 1,y + 1,jumpcnt));
f[x][y][jumpcnt] = tmp + a[x][y];
vis[x][y][jumpcnt] = true;
return f[x][y][jumpcnt];
}
int ans = -INF ,an1,an2;
int main() {
n = read(),m = read(), c1 = read(),c2 = read();
for(int i = 1;i <= m;++ i) for(int j = 1;j <= n;++ j)
a[i][j] = read();
for(freq = 1;freq <= 5;++ freq)
for(h = 1;h * freq < m;++ h) {
memset(vis,0,sizeof vis);
memset(f,0,sizeof f);
int sum = dfs(1,0,m) - (h - 1) * c1 - (freq - 1) * c2;
if(sum > ans) ans = sum , an1 = h, an2 = freq;
}
if(ans > 0) printf("%d %d %d\n",ans,an2,an1);
else puts("mission failed");
return 0 ;
}

bzoj3628: [JLOI2014]天天酷跑的更多相关文章

  1. [JLOI2014]天天酷跑

    请允许我对记忆化搜索进行一个总结,我认为所有的搜索只要数据范围允许,都可以转化为记忆化搜索, 只是,用处的多与少的关系,其本身是求出设出状态之后,为求出当前状态进行递推(搜索),推到 已知状态,之后再 ...

  2. Android版xx助手之天天酷跑外挂具体分析

    Android版xx助手之天天酷跑外挂具体分析 图/文      莫灰灰 背景 近些年来,移动互联网的大肆崛起,潜移默化中影响着人们的生活和工作习惯.当腾讯的微信平台接入手机游戏之后,移动端的游戏也開 ...

  3. 程序游戏推荐(C语言贪吃蛇,python天天酷跑(需要安装pygame),js是狠人就坚持30s)

    下面是下载位置,我把他们上传到我的文件下了. C语言贪吃蛇:https://files.cnblogs.com/files/ITXiaoAng/%E8%B4%AA%E5%90%83%E8%9B%87. ...

  4. cocos2d 简单的日常高仿酷跑游戏

    1.第一个直接看看这个游戏看起来视频(GIF我们不能满足游戏展) 跑酷游戏最纠结的是地图.碰撞倒是简单,能够自己写或者使用box2d等物理引擎.跑酷游戏地图的特点就是随机性.可是随机中又有策划特意安排 ...

  5. [置顶] cocos2d-x 植物大战僵尸(13)类似酷跑的【同一角色不同动画间的切换的实现】

          有几天没和大家分享博客了,原因很简单,就是我在运行第12章所写的代码时:(开始一切正常,不过没多久就出现了内存泄露!.可能求成心切吧,当时没多加考虑就把代码发上去了.我在此对看过第12章得 ...

  6. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  7. 站在风口,你或许就是那年薪20w+的程序猿

    最近面试了一些人,也在群上跟一些群友聊起,发现现在的互联网真是热,一些工作才两三年的期望的薪资都是十几K的起,这真是让我们这些早几年就成为程序猿的情何以堪!正所谓是站在风口上,猪也能飞起来!我在这里就 ...

  8. 相关query挖掘

    1.何为相关query 我通常也把相关query称为相似query,搜索日志中一个用户在短时间内的一系列搜索词被称为相关query.相关就是两个query间有一定的关系,反映了用户在当时的需求.本文就 ...

  9. iOS开发之如何跳到系统设置里的各种设置界面

    跳到更多设置界面 除了跳到WiFi设置界面,能不能跳到其他的设置界面呢?比如:定位服务.FaceTime.音乐等等.都是可以的,一起来看看如何实现的! 定位服务 定位服务有很多APP都有,如果用户关闭 ...

随机推荐

  1. 流媒体服务器之————EasyDarwin开源流媒体服务器:编译、配置、部署

    源码下载地址:https://github.com/EasyDarwin/EasyDarwin/archive/v7.0.5.zip 查看 Ubuntu 的版本号 sudo lsb_release - ...

  2. python学习笔记7-excel操作

    一.操作excel import xlwt book = xlwt.Workbook() #新建一个excel sheet = book.add_sheet('sheet1') #添加一个sheet页 ...

  3. HDU 1229 还是A+B(A+B陶冶情操)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1229 解题报告:A+B #include<cstdio> int main() { int ...

  4. Mahalanobis距离(马氏距离)的“哲学”解释

    讲解教授:赵辉 (FROM : UESTC) 课程:<模式识别> 整理:PO主 基础知识: 假设空间中两点x,y,定义: 欧几里得距离, Mahalanobis距离, 不难发现,如果去掉马 ...

  5. Spring bean 配置

    1.传统的创建对象的方式:JedisMall tardition=new JedisMall(); 这样是在程序运行时创建,表示当前模块已经不知不觉和new出的对象耦合了,而我们通常都是更高层次的抽象 ...

  6. springcloud注解@EnableDiscoveryClient与@EnableEurekaC

    spring cloud中discovery service有许多种实现(eureka.consul.zookeeper等等),@EnableDiscoveryClient基于spring-cloud ...

  7. 08 Go 1.8 Release Notes

    Go 1.8 Release Notes Introduction to Go 1.8 Changes to the language Ports Known Issues Tools Assembl ...

  8. 移动端调试利器之vconsole

    说明 由于移动端项目在手机中调试时不能使用chrome的控制台,而vconsole是对pc端console的改写 使用方法 使用 npm 安装: npm install vconsole 使用webp ...

  9. 为什么不要在Spring的配置里,配置上XSD的版本号

    为什么不要在Spring的配置里,配置上XSD的版本号?因为如果没有配置版本号,取的就是当前jar里的XSD文件,减少了各种风险.而且这样约定大于配置的方式很优雅.

  10. Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp

    D - Jzzhu and Numbers 这个容斥没想出来... 我好菜啊.. f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥. 求f[ S ] ...