64 735
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #37995 in C++ for Eliana

Question #37995
The way a Knight Given a chessboard, consisting of n×n cells, several of them are cut. Find the path of minimum length for a Knight from one cell to another. The Knight can’t go through cut cells.
Specifications

Input

The first row is set to the number n (2 ≤ n ≤ 50). Each of the next n lines contains n symbols. The symbol # denotes the cut cell, the point - not cut cell, the symbol @ denotes the initial and final cell of the Knight's path (the chessboard contains two such characters).

Output If the path can not be constructed, print "Impossible". Otherwise display the same map as the input, but check all Knight intermediate positions with symbol @. Example
Example input

5
.....
.@@..
.....
.....
.....
5
@..@.
..##.
.....
.....
.....
5
@....
..#..
.#...
.....
....@


Example output

Sample 1
...@.
.@@..
....@
.....
.....
Sample 2
@..@.
..##.
.@..@
..@..
@....
Sample 3
Impossible
Expert's answer
Dear customer,
Unfortunately, your question requires a lot of work and cannot be done for free.
Please submit it with all requirements as an assignment to our control panel and
we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions