Editorial for IOI '98 P5 - Camelot
Submitting an official solution before solving the problem yourself is a bannable offence.
Camelot is a combinatory problem conceived to test bottom-up structuring techniques to avoid repetitive computations. To avoid the state space explosion that occurs with a naïve search algorithm, the contestants should develop a disciplined way of performing the required calculations by using, for instance, tabulation techniques.
Overall description
The general idea can be described as follows.
For each board position , an cost matrix is computed. This cost matrix reflects the minimal number of moves required for a knight, at , to reach each square of the board. Among them, there are the cost matrices for the knights mentioned in the source problem.
For the King, the corresponding cost matrix is also computed.
If no encounters were allowed, by summing up all these matrices, a global matrix is obtained. The minima of the global matrix will define the gathering points of minimal cost.
In our case, we also need to consider, for each knight , the possibility of an encounter with the King.
Therefore, each cell of the matrix contains the minimum cost of joining with the King at . We then consider, for each possible final gathering point the minimum cost of knight travelling from each such to plus the cost recorded at in .
By this, we obtain a combined cost matrix for the situation where each knight meets the King. By adding each of these matrices with those of the remaining knights, we obtain the minima for the case where the chosen Knight meets the King. We then take the global minimum over all possible Knight-King matings.
Complexity
The complexity of the solution is linear in the number of knights.
Comments