You are asked to navigate a maze. Initially, you are placed at a certain position (the starting position) in the maze and is asked to try to reach another position (the goal position). Positions in the maze will either be open or blocked with an obstacle. Positions are identified by (x,y) coordinates. There are some rules in this problem:
To make this problem more concrete, we will consider the maze represented by a matrix of characters. A maze includes:
There is an empty line at the end of output.
Each input contains exactly one10-by-10 maze with one S and one G. If a solution exists, its simple path is unique; unsolvable mazes are allowed. Replace every cell of that path, including S and G, by +, as in the existing sample.
範例輸入 1
S..####### ##.......# #####.#### #####.#### .#........ #####.#### #####..... .#....#### ###.#..... #########G
範例輸出 1
+++####### ##++++...# #####+#### #####+#### .#...+.... #####+#### #####+.... .#...+#### ###.#+++++ #########+
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.