March 2023 C/C++ (Level 7) real test analysis#中国电子学院#National Youth Software Programming Level Examination

Insert image description here

C/C++ Programming (Levels 1~8) All real questions・Click here

Question 1: Getting out of the maze

When you stand in a maze, you are often disoriented by the intricate roads. If you can get the maze map, things will become very simple.
Suppose you have got a drawing of an n*m maze, please find the shortest path from the starting point to the exit.
Time limit: 1000
Memory limit: 65536
input
The first line is two integers n and m (1<=n, m<=100), indicating the number of rows and columns of the maze. The next n lines, each with a string of m length, represent the layout of the entire maze. The character '.' means an open space, '#' means a wall, 'S' means a starting point, and 'T' means an exit.
Output
Output the minimum number of steps needed to go from the starting point to the exit.
Sample input
3 3
S#T
.#.

Sample output
6

Here's a solution written in C:

#</

Guess you like

Origin blog.csdn.net/gozhuyinglong/article/details/132656164