[1001]
Deep Search.
Pruning 1: If the walking space is smaller than the required number of steps, you do not need to perform a deep search. Pruning is performed before the start of search.
Pruning 2: Each empty box has a certain parity. If the parity is different, you do not need to perform further searches.
[1002]
Search.
Each time it expands in four directions.
If a vertex has a number, the vertex is placed in the queue again and the number is reduced by one until the number is 0 when the vertex is read.
At the same time, for each node to record its precursor, when the search ends printing, it can be output based on the recursive Access Node of the precursor.
[1003]
Because the data size is small, you can simply enumerate the number in the range and then perform a calculation to find the maximum value.
If the number of cases is large, you can record it in an array and call it when enumerating.
In fact, we can also use tree arrays and other data structures to optimize the query complexity to O (lgn ).
The St algorithm can make the query complexity O (1 ).
Note that a 64-bit integer is required.
Note that I may be larger than J.
[1004]
Simple question.
[1005]
Simple and wide search questions.