晦涩的题意+各种傻逼害我调了那么久,实际上题目就是一个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. 关于datagridview的一些操作

    1.绑定datatable时,会显示出不需要显示的列可以加datagridview.AutoGenerateColumns = false; 2.如果datagridview的某列是数值型的,有小数, ...

  2. C 简单处理excel 转成 json

    引言 工作中常需要处理excel转json问题. 希望这篇博文能简单描述这个问题.并提供一种解决思路.提升感悟. 今天我们处理的事就是为了把 xlsm => json. 一种方式是. 去 goo ...

  3. .NET开源工作流RoadFlow-流程设计-流程属性设置

    打开流程设计器点击新建流程后会弹出新流程属性设置框,属性设置包括基本信息,数据连接和标识字段三项设置. 1.基本信息 流程ID:系统自动给每个流程分配的一个唯一ID. 流程名称:给您的新流程取一个名称 ...

  4. SQL0294N 容器已在使用中。 SQLSTATE=42730

    在建立数据库后,建立表空间时,出现如下错误: CREATE TABLESPACE TABLESAPCE_NAME PAGESIZE 32K MANAGED BY SYSTEM USING ('E:\D ...

  5. 6月24日AppCan移动开发者大会礼品清单遭泄露

    6月24日,第一届AppCan移动开发者大会将在北京国际会议中心举办,大会以”平台之上,应用无限”为主题,全景展现移动应用发展趋势.AppCan 移动技术蓝图及80万开发者的技术实践成果. 大会现场礼 ...

  6. poj 2887 Big String

    题目连接 http://poj.org/problem?id=2887 Big String Description You are given a string and supposed to do ...

  7. iOS学习之Object-C语言类和对象

    一.OC语言的特点:封装,继承,多态:包含一个运行时系统:类库丰富. 二.面向对象      1.概述      OOP(Object Oriented Programming)面向对象编程.     ...

  8. [IOS] Storyboard全解析-第一部分

    (Storyboard)是一个能够节省你很多设计手机App界面时间的新特性,下面,为了简明的说明Storyboard的效果,我贴上本教程所完成的Storyboard的截图: 现在,你就可以清楚的看到这 ...

  9. chmod命令用法

    指令名称 : chmod  使用权限 : 所有使用者  使用方式 : chmod [-cfvR] [--help] [--version] mode file...  说明 : Linux/Unix ...

  10. 整理了一下 jQuery 的原型关系图,理解起来更加方便一些。

    图例:黄色的为对象,蓝色的为函数.