Advertisement
Agentleader1

Luke

Apr 24th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. 9. Luke
  2. Program Name: `Luke.java`
  3. Input File: `luke.dat`
  4.  
  5. Luke Skywalker is being sought all over the galaxy, by the New Order led by his nephew Kylo Ren (aka Ben Solo),
  6. 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.
  7.  
  8. 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).
  9.  
  10. *Input*
  11. 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.
  12.  
  13. *Output*
  14. For each data set, output either "yes" or "no."
  15.  
  16. *Sample Input*
  17. ```20
  18. XXXXXXXXXXXXXXXXXXXX
  19. X.XXXXX......XXXX.XX
  20. X.XXXXX.XXX.XXX..XXX
  21. X.XXXXX.XXX.XXX.XXXX
  22. X.XXXXX.XXX.XXX.X..X
  23. X.XXXXX.XXX.....X.XX
  24. X.......XXX.XXX.X.XX
  25. XXXXXXXXXXX.XXX...XX
  26. XXXXXXXXXXX.XXXLXXXX
  27. X......XXXX.XXX.XXXX
  28. X.XXXXX.XXXXXXX.XXXX
  29. X.X..XX...XXXXX.XXXX
  30. X.XX.XX.X.XX....XXXX
  31. X.XX.XX.X.XX.XX.....
  32. X....XX.X.XX.XX.XXXX
  33. XXXXXXX.X.XX.XX.X...
  34. ........X.XX.XXXX.XX
  35. XXX.XXX.X.XXXXXXXXXX
  36. XXX.XXX.............
  37. XXX.XXXXXXXXXXXXXXXX
  38. 4
  39. 1 1
  40. 15 17
  41. 16 12
  42. 11 3```
  43.  
  44. *Sample Output*
  45. ```yes
  46. no
  47. yes
  48. no```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement