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

    https://github.com/shaojiankui/IOS-Categories

  2. Android--将Bitmip转化成字符串

    因为自己做的东西想要上传到服务器,所以就选择了将Bitmip转化成了字符串在上传 其它格式的图片我们好像可以用Bitmap.Factory 去将他们转化成BitMap 转化成字符串的代码 //将bit ...

  3. WIN服务器出现 php-cgi.exe - FastCGI 进程意外退出

    既然是不能解析PHP,那就直接运行一下PHP,看会报什么错,再对症下药,于是,在命令提示符窗口进入php安装的根目录,然后运行php -v的命令,这时窗口弹出计算机丢失msvcr110.dll的错误, ...

  4. libevent 定时器示例

    程序执行结果: 每隔2秒,触发一次定时器. (2)98行:evtimer_assign在event.h中定义如下: 再来看看event_assign函数: ev     要初始化的事件对象 base  ...

  5. [CentOS 6.5 X64]讓firefox java plugin 啟動

    到ORACLE下載JRE http://www.oracle.com/technetwork/java/javase/downloads/index.html 我是X64所以下載 jre-7-linu ...

  6. iOS Bluetooth Reconnect

    蓝牙的重连主要分为以下两种: 1.恢复一些已知的设备,已知的设备就是在此次操作之前你扫描到的或者已经连接过的设备.用retrievePeripheralsWithIdentifiers:函数去完成回复 ...

  7. SharePoint 2010 用xsl文件定制列表样式

    有时候我们不希望列表用默认的方式显示,要我们自定义的方式定制.其中有一种方式是使用xsl文件. 在AllItems.aspx页面中,列表是以webpart的形式显示在页面上的,webpart类型是Xs ...

  8. 60.ISE PhysDesignRules ERROR

    PhysDesignRules:2100 - Issue with pin connections and/or configuration on block:<U_ila_pro_0/U0/I ...

  9. DHCP Server软件使用教程

    DHCP Server软件使用教程 前提网络环境配置 电脑连接上wifi 网络和共享中心中更改适配器,共享无线网卡给以太网网卡 手动设置以太网网卡ipv4地址为192.168.1.1,子网掩码为255 ...

  10. Qt:禁止qDebug的输出

    Qt:禁止qDebug的输出 在工程的.pro文件里加上以下编译批令即可: DEFINES += QT_NO_DEBUG_OUTPUT