String painter--区间dp

String painter

题目大意

给你a,b两个长度相等的字符串,每次操作可以选择将a的一个区间全变成同一个字符,求将a变成b的最小操作次数

题目思路:

首先考虑最坏的情况,无非是不考虑a字符,都一个一个变,这样操作次数为n。那么在这样的操作方案下,可以想到,"每次只替换一个字符"可以等价于"每次替换一个区间然后这个区间的其他字符再被其它操作选择性覆盖",只要区间选得合适,那么后面的操作就可以不用替换掉这个字符从而节省操作。可以想到只要选取两端点相同的区间就行,这样可以节省一次操作。如果a[i]==b[i]本就不用替换,那么究竟是否还依然要选择一个两端点相等的区间呢?如果本就不用替换,其实选择一个区间a[i,k]替换与只选择a[k]替换都是同样的操作,我们可以只选择a[k]替换,也就是当a[i]==b[i]时就不用管i了。设dp[l,r]为区间[l,r]的最小操作次数,则if(a[l]!=b[l]) {dp[l,r]=r-l+1,if(b[l]==b[k]) dp[l,r]=min(dp[l,r],dp[l+1,k-1]+1+dp[k+1,r])}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Whether you are making a road, a ramp, a path or a river, Path Painter makes terrain based path creation and texturing a breeze! Path Painter allows you to: - Create paths; - Create ramps; - Create roads; - Create plateaus for secret forts; - Create lake and river beds; - Change terrain elevation along path; - Re-texture along path embankments; - Clear grass and trees along path; - Use various algorithms for natural clearing; - Standard Unity terrain compatible! Path Painter is a collaboration between Frank Slater and Procedural Worlds, and we are very excited to be working together. Note: This asset is provided in DLL form rather than with source code. If you would also like to purchase the source then please contact us directly. Our Product Suite: Gaia - A world generation system for creating, texturing, planting and populating scenes from low poly mobile, VR and through to high end desktop. GeNa 2 - A sophisticated localised level design tool that augments Gaia’s broad brush strokes, by working intuitively to give fine grained control. Path Painter - A powerful path and easy to use road, path and river bed painting system for Unity 3D. CTS - Nominated by Unity of as one of the best assets in 2017, a PBR terrain shading system that significantly improves terrain look, performance and usability. SECTR - A suite of performance-enhancing tools that enable open world streaming, massive mobile games and includes the latest techniques in audio occlusion and propagation. Pegasus - A system that can drive anything along a path. Great for cut-scenes, and even has an ambient ai that supports formations, animation and local avoidance for your npc's and animals! Want To Know More ? Unity Forum Path Painter Tutorials Have A Chat Ticketed Support NOTE: Path Painter does not create meshes, so if you are making rivers you would typically also use another tool as well to shade the river component.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值