티스토리 뷰

학교공부/JAVA

[JAVA] 미로 탈출

yunmap 2017. 7. 26. 20:28
DESCRIPTION

Top-Left 모서리에서 Bottom-Right 모서리까지 장애물을 피해서 이동하는데 필요한 최소 이동횟수를 구하라.

8*8 판

.  길

X 장애물

(Create a maze) Write a program that will find a path in a maze, as shown in Figure 18.13a. The maze is represented by an 8 * 8 board. The path must meet the following conditions:

  • The path is between the upper-left corner cell and the lower-right corner cell in the maze.
  • The program enables the user to place or remove a mark on a cell. A path consists of adjacent unmarked cells. Two cells are said to be adjacent if they are horizontal or vertical neighbors, but not if they are diagonal neighbors.
  • The path does not contain cells that form a square. The path in Figure 18.13b, for example, does not meet this condition. (The condition makes a path easy to identify on the board.)

 

 

INPUT

Line 1 ~ 8 : 한 줄당 8개의 문자로 이루어진 미로 줄

OUTPUT

Line 1 : 최단거리 

SAMPLE INPUT
........
xxx.....
..x....x
..x...x.
...xx..x
........
........
........
SAMPLE OUTPUT
14
SOURCE

JAVA2015 PE18.26


'학교공부 > JAVA' 카테고리의 다른 글

[JAVA] 문자열 순열  (0) 2017.07.26
[JAVA] Fibonacci numbers  (0) 2017.07.26
[JAVA] Factorial  (0) 2017.07.26
[JAVA] 유리수 클래스2  (0) 2017.07.26
[JAVA] 유리수 클래스1  (0) 2017.07.26
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함