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]天天酷跑的更多相关文章
- [JLOI2014]天天酷跑
请允许我对记忆化搜索进行一个总结,我认为所有的搜索只要数据范围允许,都可以转化为记忆化搜索, 只是,用处的多与少的关系,其本身是求出设出状态之后,为求出当前状态进行递推(搜索),推到 已知状态,之后再 ...
- Android版xx助手之天天酷跑外挂具体分析
Android版xx助手之天天酷跑外挂具体分析 图/文 莫灰灰 背景 近些年来,移动互联网的大肆崛起,潜移默化中影响着人们的生活和工作习惯.当腾讯的微信平台接入手机游戏之后,移动端的游戏也開 ...
- 程序游戏推荐(C语言贪吃蛇,python天天酷跑(需要安装pygame),js是狠人就坚持30s)
下面是下载位置,我把他们上传到我的文件下了. C语言贪吃蛇:https://files.cnblogs.com/files/ITXiaoAng/%E8%B4%AA%E5%90%83%E8%9B%87. ...
- cocos2d 简单的日常高仿酷跑游戏
1.第一个直接看看这个游戏看起来视频(GIF我们不能满足游戏展) 跑酷游戏最纠结的是地图.碰撞倒是简单,能够自己写或者使用box2d等物理引擎.跑酷游戏地图的特点就是随机性.可是随机中又有策划特意安排 ...
- [置顶] cocos2d-x 植物大战僵尸(13)类似酷跑的【同一角色不同动画间的切换的实现】
有几天没和大家分享博客了,原因很简单,就是我在运行第12章所写的代码时:(开始一切正常,不过没多久就出现了内存泄露!.可能求成心切吧,当时没多加考虑就把代码发上去了.我在此对看过第12章得 ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 站在风口,你或许就是那年薪20w+的程序猿
最近面试了一些人,也在群上跟一些群友聊起,发现现在的互联网真是热,一些工作才两三年的期望的薪资都是十几K的起,这真是让我们这些早几年就成为程序猿的情何以堪!正所谓是站在风口上,猪也能飞起来!我在这里就 ...
- 相关query挖掘
1.何为相关query 我通常也把相关query称为相似query,搜索日志中一个用户在短时间内的一系列搜索词被称为相关query.相关就是两个query间有一定的关系,反映了用户在当时的需求.本文就 ...
- iOS开发之如何跳到系统设置里的各种设置界面
跳到更多设置界面 除了跳到WiFi设置界面,能不能跳到其他的设置界面呢?比如:定位服务.FaceTime.音乐等等.都是可以的,一起来看看如何实现的! 定位服务 定位服务有很多APP都有,如果用户关闭 ...
随机推荐
- Scala进阶之路-Scala函数篇详解
Scala进阶之路-Scala函数篇详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.传值调用和传名调用 /* @author :yinzhengjie Blog:http: ...
- uva 10625 Board Wrapping
https://vjudge.net/problem/UVA-10652 给出n个长方形,用一个面积尽量小的凸多边形把他们围起来 求木板占包装面积的百分比 输入给出长方形的中心坐标,长,宽,以及长方形 ...
- bzoj千题计划174:bzoj1800: [Ahoi2009]fly 飞行棋
http://www.lydsy.com/JudgeOnline/problem.php?id=1800 圆上两条直径构成矩形的对角线 #include<cstdio> using nam ...
- 【洛谷 P2726】 [SHOI2005]树的双中心(树的重心)
先考虑一个\(O(N^2)\)做法. 设选的两个点为\(x,y\),则一定可以将树分成两个集合\(A,B\),使得\(A\)集合所有点都去\(x\),\(B\)集合所有点都去\(y\),而这两个集合的 ...
- 第10月第1天 iOS crash
1. find /Applications/Xcode6.1.app -name symbolicatecrash -type f tempdeMac-mini:crash temp$ dwarfdu ...
- CTEX windedt 打开中文tex乱码问题
% !TEX encoding = System % !TEX program = pdflatex % !TEX encoding = System% !TEX program = pdflatex ...
- linux下brctl配置网桥
原文:http://zhumeng8337797.blog.163.com/blog/static/1007689142011643834429/ 先装好网卡,连上网线,这是废话,不用说了. 然后开始 ...
- python数据库操作 - MySQL入门【转】
python数据库操作 - MySQL入门 python学院 2017-02-05 16:22 PyMySQL是Python中操作MySQL的模块,和之前使用的MySQLdb模块基本功能一致,PyMy ...
- jquery-easyui:如何设置组件属性
在这里以面板为例: $().ready(function() { $('#menu').tree({ url : '/menu', onClick : function(node) { $('#cen ...
- 三、vue脚手架工具vue-cli的使用
1.vue-cli构建 vue-cli工具构建:https://blog.csdn.net/u013182762/article/details/53021374 npm的镜像替换成淘宝 2.项目运行 ...