晦涩的题意+各种傻逼害我调了那么久,实际上题目就是一个dp[i][j],dp[i][j]表示第i层第j个最少需要多少时间,当我们去更新dp[i][j]的时候,考虑的是从第i+1层的某一个dp[i+1][k]往上顶一层,然后走到dp[i][j]的位置,当然往上跳的时候要注意不要碰到怪物墙壁,各种坑,我的码力果然不行呀- -0

#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#define maxn 2500
#define maxw 220
using namespace std; int dp[maxn][maxw];
char num[maxn][maxw];
char type[maxn][maxw];
int n, w;
int t1, t2, t3; int main()
{
while (cin >> n >> w)
{
scanf("%d%d%d", &t1, &t2, &t3);
for (int i = 1; i <= n; i++){
scanf("%s", type[i] + 1);
scanf("%s", num[i] + 1);
}
memset(dp, 0x3f, sizeof(dp));
dp[n][1] = 0; int tmp = 0;
//if (type[n][1] == '|' || num[n][1] == '0'||type[n][1]=='#') dp[n][1] = 0x3f3f3f3f;
for (int i = 2; i <= w; i++){
if (dp[n][1] == 0x3f3f3f3f) break;
if (type[n][i] == '|' || num[n][i] == '0'){
break;
}
if (type[n][i] == '#') tmp += t3;
tmp += t1;
dp[n][i] = tmp;
}
for (int i = n - 1; i >= 1; i--){
for (int j = 1; j <= w; j++){
if (type[i][j] == '|'||num[i][j]=='0') continue;
int k = j - 1;
int cost = 0;
if (type[i][j] == '#') cost += t3;
bool flag = false;
while (k >= 1){
if (type[i][k] == '|') break;
if (num[i][k] == '0'){
flag = true;
}
if (type[i][k +1] != '#') dp[i][j] = min(dp[i][j], dp[i + 1][k] + cost + (num[i][k] - '0' + 1)*t2);
if (type[i][k] == '#') cost += t3;
cost += t1;
k--;
if (flag) break;
}
k = j + 1;
cost = 0;
flag = false;
if (type[i][j] == '#') cost += t3;
while (k <= w){
if (type[i][k] == '|') break;
if (num[i][k] == '0'){
flag = true;
}
if (type[i][k - 1] != '#') dp[i][j] = min(dp[i][j], dp[i + 1][k] + cost + (num[i][k] - '0' + 1)*t2);
if (type[i][k] == '#') cost += t3;
cost += t1;
k++;
if (flag) break;
}
}
}
int ans = 0x3f3f3f3f;
for (int i = 1; i <= w; i++){
ans = min(dp[1][i], ans);
}
if (ans == 0x3f3f3f3f) puts("-1");
else cout << ans << endl;
}
return 0;
}

ZOJ 3555 Ice Climber(dp)的更多相关文章

  1. ZOJ3555 Ice Climber(dp)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Ice Climber Time Limit: 2 Seconds      Me ...

  2. Bomb HDU - 3555 (数位DP)

    Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...

  3. ZOJ Problem Set - 3822Domination(DP)

    ZOJ Problem Set - 3822Domination(DP) problemCode=3822">题目链接 题目大意: 给你一个n * m的棋盘,每天都在棋盘上面放一颗棋子 ...

  4. HDU(3555),数位DP

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others ...

  5. HDU 3555 Bomb 数位dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...

  6. zoj 3537 Cake 区间DP (好题)

    题意:切一个凸边行,如果不是凸包直接输出.然后输出最小代价的切割费用,把凸包都切割成三角形. 先判断是否是凸包,然后用三角形优化. dp[i][j]=min(dp[i][j],dp[i][k]+dp[ ...

  7. hdoj 3555 Bomb(DFA+dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 思路分析:该问题要求求解1—N中的数中含有49的数的个数,可以使用DFA来递推dp公式:详细解释 ...

  8. ZOJ 3623 Battle Ships DP

    B - Battle Ships Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Subm ...

  9. zoj 2860 四边形优化dp

    Breaking Strings Time Limit: 2 Seconds        Memory Limit: 65536 KB A certain string-processing lan ...

随机推荐

  1. 苹果内付费 IAP

    创建app内购买项目 消耗型项目:对于消耗型App内购买项目,用户每次下载时都必须进行购买.一次性服务通常属于消耗型项目,例如钓鱼App 中的鱼饵. 非消耗型项目:对于非消耗型App内购买项目,用户仅 ...

  2. node.js 使用 UglifyJS2 高效率压缩 javascript 文件

    UglifyJS2 这个工具使用很长时间了,但之前都是在 gulp 自动构建 时用到了 UglifyJS 算法进行压缩. 最近玩了一下 UglifyJS2 ,做了一个 在线压缩javascript工具 ...

  3. 嵌入式web服务

    :boa.thttpd.mini_httpd.shttpd.lighttpd.goaheand.appweb和apache等. Boa 1.介绍 Boa诞生于1991年,作者Paul Philips. ...

  4. metaq

    MetaQ(全称Metamorphosis)是一个高性能.高可用.可扩展的分布式消息中间件,思路起源于LinkedIn的Kafka,但并不是Kafka的一个Copy.MetaQ具有消息存储顺序写.吞吐 ...

  5. [转]What’s Behind Ericsson’s OpenWebRTC Project?

    [转]What’s Behind Ericsson’s OpenWebRTC Project? http://www.tuicool.com/articles/z6rAVrJ Ericsson’s O ...

  6. database first表更新一个表会更新所有的model,包括添加验证代码,解决办法

    因为model类是自动生成的,重新生成后会覆盖自己的修改.一个比较合理做法,就是用 partial class的方式来实现. 比如有一个Model类: Movie.那我们就可以添加一个局部类文件,局部 ...

  7. Python实现CART(基尼指数)

    Python实现CART(基尼指数) 运行环境 Pyhton3 treePlotter模块(画图所需,不画图可不必) matplotlib(如果使用上面的模块必须) 计算过程 st=>start ...

  8. Html5最简单的游戏Demo——Canvas绘图的弹弹球

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

  9. xml基础学习笔记01

    注意:刚刚看了网上对于XML中的标签,节点和元素?到底应该怎么表述?起初我也有这个疑惑,现在我的想法是:下面出现node的应称作节点,节点对象.element应称作元素,毕竟这更符合英文的本意.至于标 ...

  10. SQL中的5种聚集函数

    作为一个刚毕业进入这行的菜鸟,婶婶的觉的那种大神.大牛到底是怎样炼成的啊,我这小菜鸟感觉这TMD要学的东西这多啊,然后就给自己定了许多许多要学习的东西,可是有人又不停地给你灌输:东西不在多而要精通!我 ...