###### tags: `實習題目` # 這迷宮能走出去嗎? <!-- 我本來想出這題的!太狠了吧豬豬 我只好想別題了 --> 在一些簡單的小遊戲中,我們常常會用二維陣列來模擬迷宮,1標示障礙物、0標示可以移動的空間。 在迷宮中只有上下左右四個方向可以移動。 請寫一個程式,給你一個代表迷宮的二維陣列,請判斷這個迷宮能不能從起點走到終點。 Give you a 2-D array represent a maze, in this maze, 1 is wall and 0 is a space you can walk on. You can move 4 direction, up, down, left and right. Write a program to see if a maze has a way from start to the end. **Input** 輸入的第一行會包含一個數字n,代表陣列的大小是 n * n。 接下來的 n 行,每行會有 n 個值,代表陣列的內容。 每個迷宮的入口都是最左上角,最右下角是出口。 First lint pf input will be a integer number represent size of the maze.Follow by n rows and n columns every row. In the maze, left top is the start and right button is end. **Output** 如果在入口到出口間存在一條路徑的話請輸出 "Yes" ,反之則輸出 "No"。 if there is a way from start to the end then print "Yes", print "No" if not . --- **Sample Input 1** ``` 5 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 ``` **Sample Output 1** ``` Yes ``` ---- **Sample Input 2** ``` 5 0 0 0 0 0 1 1 1 1 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 ``` **Sample Output 2** ``` No ``` **本題來源:** [東華資工系OJ題目](http://oj.csie.ndhu.edu.tw/problem/PR110-08-02)