It's the night before DWITE, and we're a question short. I just finished my exams a few hours ago, but AJ is gone, studying somewhere in the bowels of the university's campus. Though instead of recycling an old question, here's a new one, albeit with a generic story.
You suddenly find yourself to be at letter A and also in a maze. Your task is to locate letter B, then letter C, then return to your starting point. Why are you doing this? I don't know. But you need to also find the shortest distance that this can be accomplished in.
- # - wall
- . - open space
- ABC - various points of interest
You can move only up/down/left/right, not through walls, and not outside of the maze's bounds.
The input file DATA4.txt will contain 5 test cases. Each case will start with 2 space-separated integers 1 <= R, C <= 10, rows and columns that describe the size of a maze, followed by R lines, each C characters long -- the actual maze.
The output file OUT4.txt will contain 5 lines of output, each being the shortest distance for the A -> B -> C -> A circuit.
1 6 #A.BC# 3 6 ##A### #C.### ##...B