数位DP

例题-4 HDU2089 不要62

统计数位中没有出现4和62的数字个数。

分析

不要4,可以在4时直接不转移。对于62,可以维护一个上一个数字填了啥,就可以像4一样判断了。

Liaoning Ship’s Voyage

Liaoning ship, which named after a province of China, is the first aircraft carrier commissioned into the People’s Liberation Army Navy. It was bought from Ukraine as a stripped hulk and was rebuilt by China as an important part of China’s blue water Navy plan. Liaoning ship has sailed far into the Pacific Ocean for serval times, which shows the power and resolve of China to defend her integrity of territory.

Now Liaoning ship is on a new voyage to the Atlantic Ocean for a maneuver! The vast maneuver region on the ocean can be seen as an n×n grid which has n×n crosspoints. Each crosspoint stands for a check point of the maneuver region. Liaoning starts from the bottom-left check point whose coordinate is (0,0), and its destination is the upper-right checkpoint whose coordinate is (n-1,n-1). The positive side of the x axis points to the right, and the positive side of the y axis points up. All check points’ coordinates are integral. During each move, Liaoning can go from one check point to its adjacent 8 check points along a straight line, and each move takes Liaoning one day. Some check points are not available to go due to the bad weather. And, as you know, on the Atlantic Ocean, there is a Bermuda Triangle in which many ships and planes were missing. Liaoning can’t take risk to go into that triangle. Of course, Liaoning can’t go outside the maneuver region. Please figure out a route for Liaoning to reach its destination as soon as possible.

分析

实际上本体是个Dijkstra,但是两点是否相连需要使用到计算几何的东西。重点就在于如何判断行进过程是否穿过了百慕大三角。

[CCPC2017杭州] Heathrock

这题意太长了,我懒得复制。

分析

额……其实就是爆搜模拟。但是状态比较多,需要记双方生命值,3个随从的生命,当前场数,魔力,体力,以及一些玄学优化。

  • 自选目标的牌一定会放在回合的较后出,因为其不会累加魔力。
  • 如果剩下的牌全踢脸也踢不死,直接返回。

之后就能跑得飞快。

[CFEDU74 E] Keyboard Purchase

当在使用一指禅键入一个字符串的时候,你需要不停的移动手指。比如说输入“af”,手指需要跨过3个键(包括终点)输入“a”和“f”。

针对一个经常输入的字符串,你可以定制一个长条键盘,使得在这个键盘上输入字符串需要移动的距离最短。

给出字符串长度$n$与字典大小$k$(小写字母的前$k$个),给出最优情况下手指需要移动的距离。

分析

这道题和之前那道marbles很像……或者说状压都挺像的。

[CF EDU72D] Coloring Edges

You are given a directed graph with n vertices and m directed edges without self-loops or multiple edges. Let’s denote the k-coloring of a digraph as following: you color each edge in one of k colors. The k-coloring is good if and only if there no cycle formed by edges of same color. Find a good k-coloring of given digraph with minimum possible k. 分析 对我这个