Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 9. Luke
- Program Name: `Luke.java`
- Input File: `luke.dat`
- Luke Skywalker is being sought all over the galaxy, by the New Order led by his nephew Kylo Ren (aka Ben Solo),
- and by the Resistance led by his sister Leia Organa Solo. Poe Dameron has recovered a map of the galaxy. You must write a program for R2D2 (who runs Java in a JVM in his circuits) to determine whether you can find Luke Skywalker's secret planet.
- The map is an NxN matrix. The letter "X" represents obstructions (stars, black holes, etc.) and "." represents passable hyperspace lanes. The letter "L" represents Luke's planet. Determine whether your starting position is contiguous with Luke's planet. You can send out probe droids in all directions up, down, left, or right (not diagonally).
- *Input*
- The first line has the size of the maze (N with 10<=N<=30). The next N lines contain the maze (NxN grid of characters). The next line contains the number of data sets (Y with Y<=N). Each subsequent line contains two integers, the coordinates of the starting point, row then column (R and C), the indices of the matrix 0 to (N-1). Each starting position will be inside the maze on a valid hyperspace lane, the "." character.
- *Output*
- For each data set, output either "yes" or "no."
- *Sample Input*
- ```20
- XXXXXXXXXXXXXXXXXXXX
- X.XXXXX......XXXX.XX
- X.XXXXX.XXX.XXX..XXX
- X.XXXXX.XXX.XXX.XXXX
- X.XXXXX.XXX.XXX.X..X
- X.XXXXX.XXX.....X.XX
- X.......XXX.XXX.X.XX
- XXXXXXXXXXX.XXX...XX
- XXXXXXXXXXX.XXXLXXXX
- X......XXXX.XXX.XXXX
- X.XXXXX.XXXXXXX.XXXX
- X.X..XX...XXXXX.XXXX
- X.XX.XX.X.XX....XXXX
- X.XX.XX.X.XX.XX.....
- X....XX.X.XX.XX.XXXX
- XXXXXXX.X.XX.XX.X...
- ........X.XX.XXXX.XX
- XXX.XXX.X.XXXXXXXXXX
- XXX.XXX.............
- XXX.XXXXXXXXXXXXXXXX
- 4
- 1 1
- 15 17
- 16 12
- 11 3```
- *Sample Output*
- ```yes
- no
- yes
- no```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement