Straightest Paths |
A digitized map is represented on a two dimensional grid as a set of points enclosed within a contour. The closed contour of the map (which can be of any rectangular shape) and the obstacles on the map (inside the contour) are marked using the character `X'. The free points on the map are designated by spaces. There are exactly two start-stop points on the map which are marked using the character `@'. The start-stop points cannot appear outside the map or on the contour of the map. There are no other points on the map except free points (spaces), obstacles (X) and start-stop points (@).
A path between two map points
runs vertically and/or horizontally through the free points on the
map (inside the map contour). The length of the path is the number
of points the path runs through, including the start-stop points.
The turns of the path are the direction changes while traversing
the path.
Each map is terminated by a line full of
underscores `_'. There are at most 40 lines and at most 80
characters in a line for each map, including the termination line.
The lines can be of different length. Input data are correct.
The standard output file contains the maps with the marked paths. Each
map is output in the same format it is read from the input file,
including the termination line, and is preceded by a line which
specifies the number of shortest paths, their length and turns as
shown in the sample output.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X X @ X X X X X X XXXXXX X X X X X X X XXXXXX X@ X X XXXXXXXXXXXXXXXXXXXXXXXXX ______________________________ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X X X @@ XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX ______________________________
6 paths, 32 points, 3 turns XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X X#############@ X X ### X # X X ##################### X XXXXXX### ###X X X###############X X X# ###X XXXXXX X@#######X X XXXXXXXXXXXXXXXXXXXXXXXXX ______________________________ 1 paths, 2 points, 0 turns XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X X X @@ XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX _______________________________