Path Mystery (DFS) - 2016 Blue Bridge Cup National Competition

1. Description of the topic

  Xiao Ming pretends to be a knight from Planet X and enters a strange castle.

  There is nothing in the castle, only the ground paved with square stones.

  Suppose the castle ground is n × n* squares. As shown below.

  According to the custom, the knight walks from the northwest corner to the southeast corner. Can move horizontally or vertically, but cannot walk diagonally or jump. Every time you go to a new square, you have to shoot an arrow to the north and the west. (There are n targets in the west wall and north wall of the castle respectively) The same square is only allowed to pass once. But you don't have to go through all the squares. If only the number of arrows on the target is given, can you infer the knight's walking route? Sometimes it is possible, like the example in the image above.

  The requirement of this question is to know the number of the target and find the walking path of the knight (the test data ensures that the path is unique)


enter description

  An integer N (0≤ N ≤20) in the first line indicates that the ground has

Guess you like

Origin blog.csdn.net/qq_43753724/article/details/130515165