| acmsguru |
|---|
| Finished |
' character if it contains a part of crater or with '
' character if there is no crater on this square. If two squares marked with '
' have the common edge they are considered as parts of one crater. There are no squares marked with '
' connected with the ocean. The whole area around the square is the ocean. The water-pipe you are to create should connect any two of craters with the ocean. It is allowed to connect more than two craters, but at least two craters should be connected. The water-pipe will consist of segments connected by edge and each segment will occupy the whole non-crater unit square. A pipe is connected with a crater if they have a common edge. You want to minimize number of squares involved into water-storage system creation. It is possible that two independent water-pipes are more efficient than one branched (see examples).
' or '
'. It is guaranteed that there are at least two craters reachable from the ocean.
' instead of '
'. If there are several solutions with the same minimal number of squares used, output any one of them. sample input | sample output |
5 7 ....... ....... ..X.... .....X. ....... | ....... ....... **X.... .....X* ....... |
sample input | sample output |
10 13 ............. ............. ..XXXXX...... ..X..X....... ..X.X.X.X.... ..X...X...... ..XXXXX...... ............. ............. ............. | ........*.... ........*.... ..XXXXX**.... ..X..X..*.... ..X.X.X.X.... ..X...X...... ..XXXXX...... ............. ............. ............. |
: in second example you are not allowed to connect a crater with the ocean via another crater. | Name |
|---|


