UVa 10559 Blocks(DP)

该博客详细介绍了UVa 10559 'Blocks'游戏的规则,其中玩家每次点击一个方块会消除包含该方块的连续同色方块段,并获得分数。文章探讨了如何通过动态规划找到消除方块的最优策略,以求得最高可能的得分。问题的关键在于设计动态规划的状态转移方程,考虑当前决策对未来决策的影响,并提供了一个优化方案来简化计算。最后,给出了解题思路和参考代码。
摘要由CSDN通过智能技术生成

Problem A

Blocks

Input: Standard Input

Output: Standard Output

Time Limit: 10 Seconds

 

Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Silver, Silver, Bronze, Bronze, Bronze, Gold.

 

The corresponding picture will be as shown below:

 

 

Figure 1

 

If some adjacent boxes are all of the same color, and both the box to its left(if it exists) and its right(if it exists) are of some other color, we call it a 'box segment'. There are 4 box segments. That is: gold, silver, bronze, gold. There are 1431 box(es) in the segments respectively.

 

Every time, you can click a box, then the whole segment containing that box DISAPPEARS. If that segment is composed of k boxes, you will get k*k</

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值