2009-05-06
2009-05-05
SRM207 Div2 Hard: CaptureThemAll
Algorithm Tutorials: How To Find a Solution (by Dumitru) より
Problem hints: At first sight this may seem like dynamic programming or backtracking. But as always, take a look into the text of the statement. After a while you should observe the following things:
- A table is given.
- The knight can jump from one cell to some of its neighbors.
- The cost of passing from a cell to another is always 1 (just one jump).
- You need to find the minimum number of steps (jumps).
Given this information we can see that the problem can be easily solved by the help of BFS. Don't get confused by the fact that connected points are represented by unconnected cells. Think of cells as points in a graph, or states (whatever you want) - and in order to pass from one point to another, the knight should be able to jump from the first to the second point.
Notice again that the most revealing hint about the BFS solution is the cost of 1 for any jump.
「ジャンプのコストが全て1」→BFSで解けるよというあからさまなヒント
2009-04-29
SRM233 Div1 Medium: SmartWordToy
Algorithm Tutorials: How To Find a Solution (by Dumitru) より